#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n, capacity;
  cin >> n >> capacity;
  long long a[n], b[n];
  long long diff[n];
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    sum += a[i];
    diff[i] = a[i] - b[i];
  }
  if (capacity >= sum) {
    cout << 0 << endl;
    return 0;
  }
  capacity = sum - capacity;
  sort(diff, diff + n);
  long long cnt = 0;
  long long i = n - 1;
  while (i >= 0 && capacity > 0) {
    capacity -= diff[i];
    cnt++;
    i--;
  }
  if (capacity > 0) {
    cout << -1 << endl;
  } else {
    cout << cnt << endl;
  }
  return 0;
}
