#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, size, sum1 = 0, sum2 = 0, sum3 = 0;
  cin >> n >> size;
  vector<int> s1;
  vector<int> s2;
  vector<int> s3;
  for (int i = 0; i < n; i++) {
    long int a, b;
    cin >> a >> b;
    s1.push_back(a);
    s2.push_back(b);
    s3.push_back(a - b);
    sum1 = sum1 + s1[i];
    sum2 = sum2 + s2[i];
  }
  if (sum2 > size) {
    cout << "-1";
    return 0;
  }
  sort(s3.rbegin(), s3.rend());
  for (int j = 0; j < n; j++) {
    if (sum1 - sum3 <= size) {
      cout << j;
      return 0;
    }
    sum3 = sum3 + s3[j];
  }
  cout << n;
  return 0;
}
