#include <bits/stdc++.h>
using namespace std;
struct song {
  long long int a;
  long long int b;
  long long int d;
};
bool cmp(song s1, song s2) {
  if (s1.d == s2.d) return s1.a < s2.a;
  return s1.d > s2.d;
}
int main() {
  long long int n, m;
  song s[100010];
  cin >> n >> m;
  long long int t = 0, u = 0;
  for (int i = 0; i < n; i++) {
    cin >> s[i].a >> s[i].b;
    s[i].d = s[i].a - s[i].b;
    t += s[i].b;
    u += s[i].a;
  }
  if (t > m) {
    cout << -1 << endl;
    return 0;
  }
  sort(s, s + n, cmp);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (u <= m) break;
    u -= s[i].d;
    ans++;
  }
  cout << ans << endl;
  return 0;
}
