#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, i, j, k, h = 0, s = 0;
  cin >> n >> m;
  long long int a[n];
  for (i = 0; i < n; ++i) {
    cin >> j >> k;
    h += j;
    a[i] = j - k;
  }
  sort(a, a + n);
  while (h > m) {
    h -= a[n - 1 - s];
    s++;
    if (s == n) break;
  }
  if (h <= m)
    cout << s << endl;
  else
    cout << "-1\n";
  return 0;
}
