#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, sum = 0, n, m;
  cin >> n >> m;
  long long ar[n], br[n], cr[n];
  for (i = 0; i < n; i++) cin >> ar[i] >> br[i];
  sort(ar, ar + n);
  sort(br, br + n);
  int r = lower_bound(br, br + n, ar[n - 1]) - br;
  if (r >= n) r = r - 1;
  for (i = n - 1; i >= r; i--) {
    sum = sum + br[i];
    if (sum >= m) {
      cout << n - i << endl;
      return 0;
    }
  }
  long long res = n - r;
  if (sum >= m)
    cout << res << endl;
  else {
    long long nm = m - sum, s = 0;
    for (i = 1; i <= n; i++) {
      s = s + ar[n - 1];
      if (s >= nm) break;
    }
    cout << i + res << endl;
  }
  return 0;
}
