#include <bits/stdc++.h>
using namespace std;
long long sum1, sum2;
int i, n, m, a[100001], b[100001], c[100001], ans;
bool cmp(int a, int b) { return a > b; }
int main() {
  cin >> n >> m;
  for (i = 1; i <= n; i++)
    cin >> a[i] >> b[i], c[i] = a[i] - b[i], sum1 += a[i], sum2 += b[i];
  if (sum2 > m) {
    cout << "-1" << endl;
    return 0;
  }
  sort(c + 1, c + n + 1, cmp);
  i = 1;
  while (sum1 > m) {
    ans++;
    sum1 -= c[i];
    i++;
  }
  cout << ans << endl;
  return 0;
}
