#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> a[100010];
pair<long long, long long> b[100010];
int main() {
  long long n, m;
  scanf("%lld", &n), scanf("%lld", &m);
  long long sum = 0;
  for (long long i = 1; i <= n; ++i) {
    scanf("%lld", &a[i].first), scanf("%lld", &a[i].second);
    b[i].first = a[i].first - a[i].second;
    b[i].second = i;
    sum += a[i].first;
  }
  if (sum <= m) {
    printf("0\n");
    return 0;
  }
  sort(b + 1, b + n + 1);
  long long cnt = 0;
  for (long long i = n; i >= 1; i--) {
    if (sum <= m) {
      break;
    } else {
      long long ind = b[i].second;
      sum -= a[ind].first;
      sum += a[ind].second;
      cnt++;
    }
  }
  if (sum > m) {
    printf("-1\n");
  } else {
    printf("%lld\n", cnt);
  }
}
