#include <bits/stdc++.h>
using namespace std;
const int inf = 987654321;
const long long int mod = 1000000007;
int N;
vector<long long int> T, W, X;
vector<pair<long long int, long long int> > TT;
priority_queue<long long int> pq;
int main() {
  scanf("%d", &N);
  T = W = vector<long long int>(N);
  TT.resize(N);
  for (int i = 0; i < N; i++) {
    scanf("%I64d %I64d", &T[i], &W[i]);
    TT[i] = pair<long long int, long long int>(T[i], W[i]);
  }
  sort(TT.begin() + 1, TT.end());
  int mini = inf;
  int cnt = 0, pos = N - 1;
  while (1) {
    while (pos > 0 && TT[pos].first > T[0]) {
      pq.push(-TT[pos].second + TT[pos].first - 1);
      pos--;
      cnt++;
    }
    mini = min(mini, cnt);
    if (pq.empty() || -pq.top() > T[0]) break;
    T[0] += pq.top();
    pq.pop();
    cnt--;
  }
  cout << mini + 1;
}
