#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n, m, i, c = 0, d = 0, s = 0;
  cin >> n >> m;
  vector<long long int> v;
  for (i = 0; i < n; i++) {
    cin >> c >> d;
    s += c;
    v.push_back(c - d);
  }
  sort(v.begin(), v.end());
  c = 0;
  for (i = n - 1; i >= 0 && s > m; i--) {
    s -= v[i];
    c++;
  }
  if (c == n) {
    if (s <= m)
      cout << c;
    else
      cout << -1;
  } else
    cout << c;
}
