#include <bits/stdc++.h>
using namespace std;
struct Node {
  int x, y, d;
} a[100010];
bool cmp(Node A, Node B) { return A.d > B.d; }
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) != EOF) {
    for (int i = 0; i < n; i++) {
      scanf("%d%d", &a[i].x, &a[i].y);
      a[i].d = a[i].x - a[i].y;
    }
    sort(a, a + n, cmp);
    long long t = 0;
    for (int i = 0; i < n; i++) t += a[i].x;
    long long ans = 0;
    int i = 0;
    while (t > m && i < n) {
      t = t - a[i].d;
      ans++;
      i++;
    }
    if (t > m) ans = -1;
    printf("%I64d\n", ans);
  }
  return 0;
}
