#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<long long> a;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    long long q, w;
    cin >> q >> w;
    sum += q;
    a.push_back(q - w);
  }
  sort(a.rbegin(), a.rend());
  int ans = 0;
  int cur = 0;
  while (sum > m) {
    if (cur == a.size()) {
      cout << -1;
      exit(0);
    }
    sum -= a[cur];
    ans++;
    cur++;
  }
  cout << ans;
}
