#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  scanf("%lld", &n);
  long long a, b;
  scanf("%lld %lld", &a, &b);
  long long ara[n - 1];
  long long pos = 0;
  priority_queue<long long, vector<long long>, greater<long long> > minQ;
  priority_queue<pair<long long, long long> > maxQ;
  for (long long i = 0; i < n - 1; i++) {
    long long x, y;
    scanf("%lld %lld", &x, &y);
    maxQ.push({x, y});
  }
  long long ans = 0, wholeans = n;
  for (long long i = 0; i < n; i++) {
    if (!minQ.empty()) {
      long long top = minQ.top();
      minQ.pop();
      if (top <= a) {
        ans--;
        a -= top;
      }
    }
    pair<long long, long long> topmax;
    while (!maxQ.empty() && (maxQ.top().first) > a) {
      topmax = maxQ.top();
      ans++;
      minQ.push(topmax.second - topmax.first + 1);
      maxQ.pop();
    }
    wholeans = min(wholeans, ans + 1);
  }
  printf("%lld\n", wholeans);
  return 0;
}
