#include <bits/stdc++.h>
using namespace std;
int main() {
  int t = 1;
  while (t--) {
    int n, m;
    cin >> n >> m;
    int a[n + 2], b[n + 2], d[n + 2];
    long long sum = 0;
    for (int i = 0; i < n; i++) {
      cin >> a[i] >> b[i];
      sum += a[i];
      d[i] = a[i] - b[i];
    }
    if (sum <= m) {
      cout << 0 << endl;
      continue;
    }
    sort(d, d + n);
    int cnt = 0;
    for (int i = n - 1; i >= 0; i--) {
      sum -= d[i];
      cnt++;
      if (sum <= m) break;
    }
    if (sum > m) {
      cout << -1 << endl;
      continue;
    }
    cout << cnt << endl;
  }
}
