#include <bits/stdc++.h>
using namespace std;
struct str {
  int a, b;
  bool operator<(const str& A) const { return a - b > A.a - A.b; }
};
int main() {
  int n, m;
  long long sum = 0;
  str arr[100002];
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &arr[i].a, &arr[i].b);
    sum += arr[i].a;
  }
  if (sum <= m) {
    printf("0");
    return 0;
  }
  sort(arr, arr + n);
  int cnt = 0;
  bool trig = false;
  for (int i = 0; i < n; i++) {
    sum -= (arr[i].a - arr[i].b);
    cnt++;
    if (sum <= m) {
      trig = true;
      break;
    }
  }
  if (trig)
    printf("%d", cnt);
  else
    printf("-1");
  return 0;
}
