#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> a(n);
  long long sum = 0;
  vector<int> d(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first >> a[i].second;
    d[i] = a[i].first - a[i].second;
    sum += (long long)a[i].second;
  }
  if (sum > m) {
    cout << -1 << endl;
    return 0;
  }
  int ans = n + 1;
  sort(d.begin(), d.end());
  m -= sum;
  for (int i = 0; i < n; ++i) {
    if (m < 0) break;
    --ans;
    m -= d[i];
  }
  if (m >= 0) ans = 0;
  cout << ans << endl;
  return 0;
}
