#include <bits/stdc++.h>
using namespace std;
long long a[100005], b[100005], d[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long n, x, m;
  while (cin >> n >> m) {
    int p = 0;
    long long sum = 0;
    vector<long long> v;
    long long sum1 = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i] >> b[i];
      v.push_back(a[i] - b[i]);
      sum += a[i];
      sum1 += b[i];
    }
    if (sum <= m) {
      cout << 0 << endl;
    } else {
      long long cnt = 0;
      sort(v.begin(), v.end());
      for (int i = n - 1; i >= 0; i--) {
        if (sum <= m) {
          break;
        }
        sum -= v[i];
        cnt++;
      }
      if (sum1 > m)
        cout << -1 << endl;
      else
        cout << cnt << endl;
    }
  }
  return 0;
}
