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