#include <bits/stdc++.h>
using namespace std;
const long long maxn = 5e5;
struct team {
  long long t, w, id;
} a[maxn];
priority_queue<long long> Qf;
priority_queue<pair<long long, long long> > Qb;
long long n, i, j, x, y, z, ans, T, W;
bool cmpw(team a, team b) { return a.t > b.t || (a.t == b.t && a.id < b.id); }
void solve() {
  if (ans == 1) return;
  for (;;) {
    long long u = -Qf.top() + 1;
    Qf.pop();
    if (u > T) return;
    T -= u;
    while (!Qb.empty() && Qb.top().first > T) {
      pair<long long, long long> u = Qb.top();
      Qb.pop();
      Qf.push(u.first - u.second);
    }
    long long x = Qf.size() + 1;
    ans = min(ans, x);
    if (ans == 1) return;
  }
}
int main() {
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) {
    scanf("%lld%lld", &x, &y);
    a[i] = (team){x, y, i};
  }
  sort(a + 1, a + n + 1, cmpw);
  for (i = 1; i <= n; i++)
    if (a[i].id == 1) {
      ans = i;
      T = a[i].t;
      W = a[i].w;
      break;
    }
  for (i = 1; i < ans; i++) Qf.push(a[i].t - a[i].w);
  for (i = ans + 1; i <= n; i++) Qb.push(make_pair(a[i].t, a[i].w));
  solve();
  printf("%lld", ans);
  return 0;
}
