#include <bits/stdc++.h>
using namespace std;
const int maxN = 2000000 + 7;
long long n, m, a[maxN], b[maxN], c[maxN], cnt, chit;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
    cnt += a[i];
    c[i] = a[i] - b[i];
  }
  sort(c + 1, c + n + 1);
  if (cnt <= m) {
    cout << 0;
    exit(0);
  }
  for (int i = n; i >= 1; i--) {
    if (cnt - c[i] <= m) {
      chit++;
      cout << chit;
      exit(0);
    }
    cnt -= c[i];
    chit++;
  }
  cout << -1;
}
