#include <bits/stdc++.h>
using namespace std;
string tostr(int n) {
  stringstream rr;
  rr << n;
  return rr.str();
}
long long power(long long a, long long b) {
  return b == 0 ?: a * power(a, b - 1);
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
int main() {
  ios::sync_with_stdio(0);
  int n, m;
  while (cin >> n >> m) {
    long long sum1 = 0, a, b, cnt = 0;
    vector<int> v;
    while (n--) {
      cin >> a >> b;
      sum1 += a;
      v.push_back(a - b);
    }
    sort(v.begin(), v.end());
    for (int i = v.size() - 1; i >= 0; i--) {
      if (sum1 > m) {
        sum1 -= v[i];
        cnt++;
      }
    }
    if (sum1 > m)
      cout << -1 << "\n";
    else
      cout << cnt << "\n";
  }
  return 0;
}
