#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, x, y;
  cin >> n >> m;
  long long diff[n];
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    diff[i] = x - y;
    sum += x;
  }
  if (sum <= m)
    cout << 0 << endl;
  else {
    sort(diff, diff + n);
    long long count = 0, f = 0;
    for (int i = n - 1; i >= 0; i--) {
      sum = sum - diff[i];
      count++;
      if (sum <= m) {
        f = 1;
        break;
      }
    }
    if (f == 1)
      cout << count << endl;
    else
      cout << -1 << endl;
  }
  return 0;
}
