#include <bits/stdc++.h>
using namespace std;
const long long N = 300;
const long long INF = 1e18;
const long long mod = 1e9 + 7;
long long sum;
int n, m;
int x, y;
vector<long long> v;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> x >> y;
    sum += x;
    v.push_back(x - y);
  }
  if (m >= sum) {
    cout << 0;
    return 0;
  }
  sort(v.begin(), v.end());
  for (int i = n - 1; i >= 0; i--) {
    sum -= v[i];
    if (m >= sum) {
      cout << n - i;
      return 0;
    }
  }
  cout << -1;
}
