#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return (b ? gcd(b, a % b) : a); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long MOD = 1e9 + 7;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n), b(n), c(n);
  for (long long i = 0; i < n; i++) cin >> a[i] >> b[i];
  for (long long i = 0; i < n; i++) c[i] = a[i] - b[i];
  sort(c.rbegin(), c.rend());
  long long sum = 0;
  for (long long i = 0; i < n; i++) sum += a[i];
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    if (sum <= m) break;
    sum -= c[i];
    ans++;
  }
  if (sum <= m)
    cout << ans;
  else
    cout << -1;
}
