#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300005;
const long long inf = (1000000000LL * 1000000000LL) + 5;
struct node {
  long long Sum;
  int cnt;
};
node tree[4 * MAXN];
void buildTree(int N) {
  for (int i = 1; i <= 4 * N; i++) tree[i].Sum = tree[i].cnt = 0;
}
void Insert(int v, int tl, int tr, int pos, long long val) {
  if (tl == tr) {
    tree[v].cnt = 1;
    tree[v].Sum = val;
  } else {
    int mid = (tl + tr) / 2;
    if (pos <= mid)
      Insert(2 * v, tl, mid, pos, val);
    else
      Insert(2 * v + 1, mid + 1, tr, pos, val);
    long long total = tree[2 * v].Sum + tree[2 * v + 1].Sum;
    tree[v].cnt = tree[2 * v].cnt + tree[2 * v + 1].cnt;
    tree[v].Sum = min(total, inf);
  }
}
int cntFuck(int v, int tl, int tr, long long ballons) {
  if (tl == tr) {
    if (ballons >= tree[v].Sum)
      return tree[v].cnt;
    else
      return 0;
  } else {
    int mid = (tl + tr) / 2;
    if (tree[2 * v].Sum >= ballons) {
      return cntFuck(2 * v, tl, mid, ballons);
    } else {
      return tree[2 * v].cnt +
             cntFuck(2 * v + 1, mid + 1, tr, ballons - tree[2 * v].Sum);
    }
  }
}
struct team {
  long long w, t;
  int idx, treePos;
  long long toFly() { return w - t + 1; }
};
bool byDifference(team A, team B) { return A.toFly() < B.toFly(); }
bool byRank(team A, team B) {
  if (A.t > B.t) return true;
  if (A.t < B.t) return false;
  return A.idx < B.idx;
}
team T[MAXN];
int main() {
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> T[i].t >> T[i].w;
    T[i].idx = i;
  }
  sort(T + 1, T + N + 1, byDifference);
  for (int i = 1; i <= N; i++) {
    T[i].treePos = i;
  }
  sort(T + 1, T + N + 1, byRank);
  buildTree(N);
  int curr = 1;
  int better = 0;
  while (T[curr].idx != 1) {
    better++;
    Insert(1, 1, N, T[curr].treePos, T[curr].toFly());
    curr++;
  }
  long long ballons = T[curr].t;
  curr++;
  T[N + 1].t = 0;
  int ans = better;
  for (int i = curr; i <= N + 1; i++) {
    long long toGive = ballons - T[i].t;
    int fuck = cntFuck(1, 1, N, toGive);
    if (i <= N) Insert(1, 1, N, T[i].treePos, T[i].toFly());
    ans = min(ans, better - fuck);
    better++;
  }
  cout << ans + 1 << endl;
  return 0;
}
