#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  multiset<long long> s;
  long long sum = 0;
  for (long long i = 0; i < n; ++i) {
    long long a, b;
    cin >> a >> b;
    sum += a;
    s.insert(a - b);
  }
  auto it = s.rbegin();
  long long ans = 0;
  while (sum > m && it != s.rend()) {
    sum -= *it;
    ++ans;
    ++it;
  }
  cout << (sum <= m ? ans : -1) << endl;
  return 0;
}
