import std.stdio;
import std.conv;
import std.string;
import std.format;
import std.algorithm;
import std.math;

//string lines = q"[
//abcdeffg]";

long INF = pow(10, 10)-1;
long V_MAX = pow(10, 6);
long[] Wi = [0L];
long[] Vi = [0L];

void main()
{
  string lines;
  string buf;

  while (!stdin.eof) {
    buf = stdin.readln();
    lines ~= buf;
  }

  string[] array = splitLines(lines);
    
  int N = array[0].split(" ")[0].to!int;
  int W = array[0].split(" ")[1].to!int;
  
  foreach (string s; array[1..N+1]) {
    Wi ~= s.split(" ")[0].to!long;
    Vi ~= s.split(" ")[1].to!long;
  }
  
  long[][] dp = new long[][](N+1, V_MAX);
  dp.each!(line => fill(line, INF));
  
  for (long i = 1; i < N+1; i++) {
    for (long j = 1; j < V_MAX; j++) {
      if (Vi[i] > j) {
        dp[i][j] = min(dp[i-1][j], Wi[i]);
      } else {
        dp[i][j] = min(dp[i-1][j], dp[i-1][j-Vi[i]] + Wi[i]);
      }
    }
  }
  
  auto ans = dp.map!(arr => arr[1..$-1].countUntil!(n => n > W)).reduce!(max) + 1;
  writeln(ans);
}