#include <algorithm>
#include <cstdio>
#include <cassert>
#include <cstdlib>

using namespace std;

void myassert( bool f, char * report )
{
  if (!f)
  {
    fprintf(stderr, "%s\n", report);
    exit(1);
  }
}

int main( void )
{
  freopen("fitness.in", "r", stdin);
  freopen("fitness.out", "w", stdout);

  int n, k;
  scanf("%d%d", &n, &k);

  myassert(1 <= n && n <= 100, "1 <= n && n <= 100");
  myassert(1 <= k && k <= 1000, "1 <= k && k <= 1000");
  
  int t = 0;
  
  for (int i = 0; i < n; i++)
  {
    int c, o;
    scanf("%d%d", &c, &o);
    myassert(c >= 0 && o >= 0, "a >= 0 && b >= 0");
    myassert(c + o <= k, "a + b <= k");
    t = max(t - c, o);
  }
  printf("%d\n", k - t);

  return 0;
}