#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(n);
  long long total = 0;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    v.push_back(a[i] - b[i]);
    total += a[i];
  }
  if (total <= m) {
    cout << 0;
    return 0;
  }
  sort(v.rbegin(), v.rend());
  for (int i = 0; i < n; i++) {
    total -= v[i];
    if (total <= m) {
      cout << i + 1;
      return 0;
    }
  }
  cout << -1;
  return 0;
}
