#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  long long mx;
  cin >> n >> mx;
  long long a[N], pfs[N] = {0};
  long long sum = 0, sumsub = 0;
  for (int i = 0; i < n; i++) {
    long long var, sub;
    cin >> var >> sub;
    sum += var;
    pfs[i] = var - sub;
    sumsub += sub;
  }
  if (sumsub > mx) {
    cout << -1 << endl;
    return 0;
  }
  if (sum <= mx) {
    cout << 0 << endl;
    return 0;
  }
  sort(pfs, pfs + n);
  reverse(pfs, pfs + n);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    sum -= pfs[i];
    cnt++;
    if (sum <= mx) {
      cout << cnt << endl;
      return 0;
    }
  }
}
