#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> vec(n);
  for (int i = 0; i < n; i++) {
    long long first, second;
    cin >> first >> second;
    vec[i] = first - second;
    m -= first;
  }
  if (m >= 0) {
    cout << 0 << endl;
    return 0;
  }
  sort(vec.rbegin(), vec.rend());
  int counter = 0;
  for (int i = 0; i < vec.size(); i++) {
    if (m >= 0) break;
    m += vec[i];
    counter++;
  }
  if (m < 0) {
    cout << -1 << endl;
    return 0;
  }
  cout << counter << endl;
}
