#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a, b;
  long long mx = 0, mn = 0;
  cin >> n >> m;
  int d[n];
  for (int i = 0; i < n; ++i) {
    cin >> a >> b;
    d[i] = a - b;
    mx += a * 1LL;
    mn += b * 1LL;
  }
  if (mn > m) {
    cout << -1 << endl;
    return 0;
  } else if (mx <= m) {
    cout << 0 << endl;
    return 0;
  }
  sort(d, d + n);
  for (int i = n - 1, j = 1; i >= 0; i--, j++) {
    mx -= d[i];
    if (mx <= m) {
      cout << j << endl;
      break;
    }
  }
}
