#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 10;
const long long INF = 0x3f3f3f3f;
long long a[maxn];
long long b[maxn];
long long d[maxn];
int32_t main() {
  long long n, m;
  cin >> n >> m;
  long long ans1 = 0;
  long long ans2 = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
    d[i] = a[i] - b[i];
    ans1 += a[i];
    ans2 += b[i];
  }
  if (ans2 > m) {
    cout << -1 << endl;
    return 0;
  }
  sort(d + 1, d + 1 + n);
  long long t = 0;
  for (long long i = n; i >= 1; i--) {
    if (ans1 <= m) break;
    ans1 = ans1 - d[i];
    t++;
  }
  cout << t << endl;
}
