#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
  long long m;
  long long n;
  cin >> n >> m;
  int sums[n];
  pair<long long, long long> songs[n];
  multimap<long long, pair<long long, long long>> listed;
  for (long long i = 0; i < n; i++) {
    long long siz;
    long long compressedSize;
    cin >> siz >> compressedSize;
    songs[i].first = siz;
    songs[i].second = compressedSize;
    sums[i] = siz - compressedSize;
    listed.insert({sums[i], {siz, compressedSize}});
  }
  multimap<long long, pair<long long, long long>>::iterator it;
  long long e = n - 1;
  for (it = listed.begin(); it != listed.end(); it++) {
    long long m = it->first;
    long long f = it->second.first;
    songs[e].first = f;
    songs[e].second = m;
    e--;
  }
  long long s = 0;
  for (int i = 0; i < n; i++) {
    s = s + songs[i].first;
  }
  long long cpy = s;
  int cnt = 0;
  int y = 0;
  bool check{true};
  while (cpy > m) {
    cpy = cpy - songs[y].second;
    y++;
    cnt++;
    if (y > n - 1) {
      if (cpy > m) check = false;
      break;
    }
  }
  if (check)
    cout << cnt << endl;
  else
    cout << "-1" << endl;
  return 0;
}
