#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n, m;
  cin >> n >> m;
  long long sum = 0, sum2 = 0;
  vector<pair<long long, long long>> v(n);
  for (long long i = 0; i < n; i++) {
    long long a, b;
    cin >> v[i].first >> v[i].second;
    sum = sum + v[i].first;
    sum2 = sum2 + v[i].second;
  }
  if (sum2 > m) {
    cout << -1;
    return 0;
  }
  if (sum <= m) {
    cout << 0;
    return 0;
  }
  long long a[n];
  for (long long i = 0; i < n; i++) a[i] = v[i].first - v[i].second;
  sort(a, a + n);
  long long diff = 0, cnt = 0;
  ;
  for (long long i = n - 1; i >= 0; i--) {
    diff = diff + a[i];
    cnt++;
    if (diff >= sum - m) {
      cout << cnt;
      break;
    }
  }
  return 0;
}
