#include <bits/stdc++.h>
using namespace std;
class node {
 public:
  int index;
  long long diff;
};
class comp {
 public:
  bool operator()(const node &lhs, const node &rhs) {
    if (lhs.diff < rhs.diff)
      return true;
    else
      return false;
  }
};
int main() {
  long long n, flash;
  scanf("%I64d %I64d", &n, &flash);
  long long bef, aft;
  long long sum = 0, sumdiff = 0;
  node temp;
  priority_queue<node, vector<node>, comp> PQ;
  for (int i = 0; i < n; i++) {
    scanf("%I64d %I64d", &bef, &aft);
    sum += bef;
    temp.index = i;
    temp.diff = bef - aft;
    sumdiff += temp.diff;
    PQ.push(temp);
  }
  if (sum - flash > sumdiff) {
    printf("-1");
    return 0;
  }
  int counter = 0;
  while (sum - flash > 0) {
    sum -= PQ.top().diff;
    counter++;
    PQ.pop();
  }
  printf("%d", counter);
}
