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