#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, i, m, s = 0, d = 0;
  cin >> n >> m;
  long long a[n], b[n], c[n];
  for (i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    s += a[i];
    c[i] = a[i] - b[i];
  }
  sort(c, c + n);
  for (i = 0; i < n; i++)
    if (s > m) {
      s = s - c[n - 1 - i];
      d++;
    }
  if (s > m)
    cout << -1;
  else
    cout << d;
}
int main() {
  long long a;
  solve();
  return 0;
}
