#include <bits/stdc++.h>
using namespace std;
const long long infl = 2e18;
const long long infi = 1e9;
const long long mod = 998244353;
auto clk = clock();
mt19937_64 rang(
    chrono::high_resolution_clock::now().time_since_epoch().count());
long long rng(long long lim) {
  uniform_int_distribution<long long> uid(0, lim - 1);
  return uid(rang);
}
long long powm(long long a, long long b) {
  long long res = 1;
  a %= mod;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
const long long N = 300005;
pair<pair<long long, long long>, long long> tw[N];
pair<long long, long long> lol[4 * N];
void update(long long seg, long long l, long long r, long long p,
            long long val) {
  if (p > r || l > p) return;
  if (l == p && p == r) {
    lol[seg].first = val;
    lol[seg].second = 1;
    return;
  }
  update(seg << 1, l, (l + r) / 2, p, val);
  update(seg << 1 | 1, 1 + (l + r) / 2, r, p, val);
  lol[seg].first = lol[seg << 1].first + lol[seg << 1 | 1].first;
  if (lol[seg].first > infl) lol[seg].first = infl;
  lol[seg].second++;
}
long long query(long long seg, long long l, long long r, long long val) {
  if (l == r) {
    return (lol[seg].first <= val) ? lol[seg].second : 0;
  }
  if (lol[seg << 1].first <= val) {
    return lol[seg << 1].second +
           query(seg << 1 | 1, (l + r) / 2 + 1, r, val - lol[seg << 1].first);
  } else
    return query(seg << 1, l, (l + r) / 2, val);
}
long long indices[N];
long long po[N];
void solve() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> tw[i].first.first >> tw[i].first.second;
    tw[i].second = i;
    indices[i] = i;
  }
  sort(indices + 2, indices + n + 1, [](long long i, long long j) {
    return tw[i].first.first - tw[i].first.second >
           tw[j].first.first - tw[j].first.second;
  });
  for (long long i = 1; i <= n; i++) {
    po[indices[i]] = i;
  }
  sort(tw + 2, tw + n + 1);
  reverse(tw + 2, tw + n + 1);
  long long ans = n;
  long long ball = tw[1].first.first;
  for (long long i = 2; i <= n; i++) {
    long long spare = ball - tw[i].first.first;
    if (spare >= 0) {
      ans = min(ans, i - 1 - query(1, 1, n, spare));
      ;
    }
    update(1, 1, n, po[tw[i].second],
           tw[i].first.second + 1 - tw[i].first.first);
    ;
  }
  ans = min(ans, n - query(1, 1, n, ball));
  cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  cout << fixed << setprecision(10);
  long long t = 1;
  while (t--) solve();
  return 0;
}
