#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  set<pair<long long, long long> > more;
  set<pair<long long, pair<long long, long long> > > less;
  long long mp_b, mp_w;
  cin >> mp_b >> mp_w;
  for (int i = 0; i < n - 1; i++) {
    long long b, w;
    cin >> b >> w;
    if (b > mp_b)
      more.insert(make_pair(w - b + 1, i));
    else
      less.insert(make_pair(b, make_pair((w - b + 1), i)));
  }
  int place = more.size() + 1;
  while (!more.empty()) {
    auto it = more.begin();
    if (it->first <= mp_b) {
      mp_b -= it->first;
      more.erase(*it);
      while (!less.empty()) {
        auto it1 = less.end();
        it1--;
        if (it1->first > mp_b) {
          more.insert(it1->second);
          less.erase(*it1);
        } else
          break;
      }
      place = min(place, (int)more.size() + 1);
    } else
      break;
  }
  cout << min(place, (int)more.size() + 1);
  return 0;
}
