{$APPTYPE CONSOLE}

const
  MaxN = 100;

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

begin
  reset(input, 'solving.in');
  rewrite(output, 'solving.out');
  read(n, A);
  for i := 1 to n do
    read(problems[i, 1], problems[i, 2]);
  fillchar(used, sizeof(used), false);
  result := 0;
  while true do begin
    i := 1;
    while (i <= n) and (used[i] or (problems[i, 1] > A))do
      inc(i);
    if i > n then
      break
    else begin
      inc(result);
      inc(A, problems[i, 2]);
      used[i] := true;
    end;
  end;
  writeln(result);
  close(input); close(output);
end.
