#include <bits/stdc++.h>
const int maxn = 1e5 + 5;
using namespace std;
struct node {
  int x, y;
} ma[maxn];
bool cmp(node A, node B) { return A.x - A.y > B.x - B.y; }
long long s = 0;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &ma[i].x, &ma[i].y);
    s += ma[i].x;
  }
  if (s <= m) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 0;
  sort(ma + 1, ma + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    s -= (ma[i].x - ma[i].y);
    ans++;
    if (s <= m) {
      break;
    }
  }
  if (s > m) {
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}
