#include <bits/stdc++.h>
using namespace std;
const int size = 1000005;
int main() {
  long long n, m, x, y, sum = 0, tot = 0;
  cin >> n >> m;
  vector<long long> v;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    tot += x;
    sum += y;
    v.push_back(x - y);
  }
  if (sum > m) {
    cout << "-1";
    return 0;
  }
  sort(v.begin(), v.end());
  int i = v.size() - 1, cnt = 0;
  while (i >= 0 && tot > m) {
    tot -= v[i];
    i--;
    cnt++;
  }
  cout << cnt << endl;
  return 0;
}
