#include <bits/stdc++.h>
using namespace std;
long long n, Maxmem, curmem, a, b, cnt = 0;
priority_queue<int> pq;
int main() {
  cin >> n >> Maxmem;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    curmem += a;
    pq.push(a - b);
  }
  while (curmem > Maxmem && !pq.empty()) {
    curmem -= pq.top();
    pq.pop();
    cnt++;
  }
  cout << (Maxmem < curmem ? -1 : cnt) << '\n';
  return 0;
}
