#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<tuple<long long, long long, long long>> v;
  long long curb = -1;
  for (int i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    if (curb == -1) curb = a;
    v.emplace_back(a, b, i);
  }
  sort(v.begin(), v.end(),
       [](const tuple<long long, long long, long long> t1,
          const tuple<long long, long long, long long> t2) {
         if (get<0>(t1) != get<0>(t2)) return get<0>(t1) > get<0>(t2);
         return get<2>(t1) < get<2>(t2);
       });
  int idx = 0;
  while (get<2>(v[idx]) != 0) idx++;
  priority_queue<long long, vector<long long>, greater<long long>> pq;
  for (int i = 0; i < idx; i++) {
    long long balloons, weight, asd;
    tie(balloons, weight, asd) = v[i];
    pq.emplace(weight - balloons + 1);
  }
  long long best = idx;
  long long gone = 0;
  while (pq.size() && get<1>(v[idx]) - get<0>(v[idx]) >= 0) {
    long long needed;
    needed = pq.top();
    pq.pop();
    if (get<0>(v[idx]) - needed < 0) break;
    get<0>(v[idx]) -= needed;
    gone++;
    while (idx + 1 < (int)v.size() && get<0>(v[idx]) < get<0>(v[idx + 1])) {
      pq.emplace(get<1>(v[idx + 1]) - get<0>(v[idx + 1]) + 1);
      swap(v[idx], v[idx + 1]);
      idx++;
    }
    best = min(idx - gone, best);
  }
  cout << best + 1;
}
