#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, i;
  cin >> n >> m;
  long long a[n], b[n], c[n], count = 0, sum = 0, sum1 = 0, ans;
  for (i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    c[i] = a[i] - b[i];
    sum = sum + a[i];
    sum1 = sum1 + c[i];
  }
  sort(c, c + n);
  ans = sum;
  if ((sum - sum1) > m) {
    cout << "-1" << endl;
  } else if (sum <= m) {
    cout << "0" << endl;
  } else {
    for (i = n - 1; i >= 0; i--) {
      ans = ans - c[i];
      count++;
      if (ans <= m) {
        break;
      }
    }
    cout << count << endl;
  }
  return 0;
}
