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