#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<pair<long long, long long> > v;
  vector<long long> dmg;
  long long maxdmg = 0;
  for (long long i = 0; i < n; ++i) {
    long long tmp, tmp1;
    cin >> tmp >> tmp1;
    maxdmg += tmp1;
    v.push_back(make_pair(tmp, tmp1));
    dmg.push_back(tmp1);
  }
  if (maxdmg >= m) {
    if (maxdmg == m)
      cout << n;
    else {
      sort(dmg.begin(), dmg.end(), greater<long long>());
      maxdmg = 0;
      long long i = 0;
      while (maxdmg < m) {
        maxdmg += dmg[i];
        i++;
      }
      cout << i;
    }
  } else {
    long long i = 0;
    sort(v.begin(), v.end());
    while (maxdmg < m) {
      maxdmg += v[n - 1].first;
      i++;
    }
    cout << i + n;
  }
  return 0;
}
