#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, a[100001], b[100001], c[100001], k = 0, x = 0, y = 0;
  ;
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    x += a[i];
    y += b[i];
    c[i] = a[i] - b[i];
  }
  sort(c, c + n);
  if (x > m && y > m)
    cout << -1;
  else {
    for (long long i = 0, j = n - 1; x > m; i++, j--) {
      x -= c[j];
      k++;
    }
    cout << k;
  }
}
