#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int m;
  cin >> n >> m;
  vector<pair<long long int, int>> v;
  long long p, q;
  long long sum = 0;
  long long summin = 0;
  for (int i = 0; i < n; i++) {
    cin >> p >> q;
    v.push_back(make_pair(p - q, i));
    sum += p;
    summin += q;
  }
  if (sum <= m) {
    cout << "0";
    return 0;
  } else if (summin < m) {
    sort(v.begin(), v.end());
    int ans = 0;
    long long temp = sum - m;
    long long tempsum = 0;
    for (int i = n - 1; i >= 0; i--) {
      tempsum += v[i].first;
      if (tempsum < temp)
        ans++;
      else
        break;
    }
    cout << ans + 1;
    return 0;
  } else if (summin == m) {
    cout << n;
    return 0;
  } else
    cout << "-1";
}
