#include <bits/stdc++.h>
using namespace std;
long long int k, n, m, i, x, ar[1000005], res, sum, mk, q, mn, ak[1000005];
int main() {
  pair<int, int> p[100005];
  scanf("%lld %lld", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &p[i].first, &p[i].second);
    ak[i] = p[i].first - p[i].second;
    sum += p[i].first;
  }
  sort(ak + 1, ak + n + 1);
  if (sum <= m) {
    printf("0");
    return 0;
  }
  while (n) {
    q++;
    sum = sum - ak[n];
    if (sum <= m) break;
    n--;
  }
  if (sum <= m)
    printf("%lld", q);
  else
    printf("-1");
}
