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