#include <bits/stdc++.h>
using namespace std;
int n;
long long B[300047];
long long W[300047];
priority_queue<pair<long long, int> > T, Q;
int main() {
  cin >> n;
  for (int i = 0; i < int(n); ++i) {
    cin >> B[i] >> W[i];
    if (i > 0) T.push({B[i], i});
  }
  int bestplace = n;
  int place = 0;
  while (B[0] >= 0) {
    while (T.size() > 0 && T.top().first > B[0]) {
      int x = T.top().second;
      T.pop();
      Q.push({-(W[x] - B[x] + 1), x});
    }
    bestplace = min(bestplace, (int)Q.size());
    if (Q.size() == 0) break;
    B[0] += Q.top().first;
    Q.pop();
  }
  cout << bestplace + 1 << endl;
}
