{$APPTYPE CONSOLE}

const
  MaxN = 100000;

var
  problems: array [1 .. MaxN, 1 .. 2] of int64;
  i, n: integer;
  A: int64;
  result: integer;

procedure swap(i, j: integer);
var
  t: int64;
begin
  t := problems[i, 1]; problems[i, 1] := problems[j, 1]; problems[j, 1] := t;
  t := problems[i, 2]; problems[i, 2] := problems[j, 2]; problems[j, 2] := t;
end;

procedure sort(l, r: integer);
var
  i, j: integer;
  x : int64;
begin
  i := l; j := r;
  x := problems[random(r - l + 1) + l, 2];
  while i < j do begin
    while problems[i, 2] < x do inc(i);
    while problems[j, 2] > x do dec(j);
    if i <= j then begin
      swap(i, j);
      inc(i); dec(j);
    end;
  end;
  if i < r then sort(i, r);
  if l < j then sort(l, j);
end;

begin
  reset(input, 'solving.in');
  rewrite(output, 'solving.out');
  randomize;
  read(n, A);
  for i := 1 to n do
    read(problems[i, 1], problems[i, 2]);
  sort(1, n);
  result := 0;
  i := 1;
  while (i <= n) and (A >= problems[i, 1]) do begin
    inc(result);
    A := A + problems[i, 2];
    inc(i);
  end;
  writeln(result);
  close(input); close(output);
end.
