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