#include <bits/stdc++.h>
using namespace std;
void myfunction(vector<int> &v1, vector<int> &v2, vector<pair<int, int> > &diff,
                int &addonn, long long int &sum) {
  int index = (diff.end() - addonn)->second;
  v1[index] = v2[index];
  sum = sum - (diff.end() - addonn)->first;
  addonn++;
  return;
}
int main() {
  int size, limit;
  cin >> size >> limit;
  vector<int> v1(size);
  vector<int> v2(size);
  vector<pair<int, int> > diff;
  for (int i = 0; i < size; i++) {
    cin >> v1[i] >> v2[i];
    diff.push_back(make_pair(v1[i] - v2[i], i));
  }
  if (accumulate(v2.begin(), v2.end(), (long long)0) > limit) {
    cout << "-1";
    return 0;
  }
  sort(diff.begin(), diff.end());
  int turns = 0;
  int addonn = 1;
  long long int sum = accumulate(v1.begin(), v1.end(), (long long)0);
  while (sum > limit && turns < size) {
    myfunction(v1, v2, diff, addonn, sum);
    turns++;
  }
  cout << turns;
  return 0;
}
