#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
long long n, m;
long long a[maxn], b[maxn], c[maxn];
long long sum;
long long ans;
bool cmp(long long a, long long b) { return a > b; }
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
    sum += a[i];
    c[i] = a[i] - b[i];
  }
  sort(c + 1, c + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    if (sum <= m)
      break;
    else
      sum -= c[i], ans++;
  }
  if (sum - m > 0)
    cout << "-1" << endl;
  else
    cout << ans << endl;
  return 0;
}
