#include <bits/stdc++.h>
using namespace std;
struct node {
  int id;
  long long bal, w;
  bool operator<(const node &t) const {
    if (bal == t.bal) return id < t.id;
    return bal > t.bal;
  }
} a[300010];
struct team {
  long long need, bal;
  bool operator<(const team &t) const { return need > t.need; }
  team(long long _need = 0, long long _bal = 0) : need(_need), bal(_bal) {}
};
priority_queue<team> q;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%I64d %I64d", &a[i].bal, &a[i].w), a[i].id = i;
  sort(a + 1, a + n + 1);
  int x, r, ans, now;
  long long bal;
  for (int i = 1; i <= n; i++)
    if (a[i].id == 1) x = i, ans = now = i, bal = a[i].bal, r = x + 1;
  for (int i = 1; i < x; i++) q.push(team(a[i].w - a[i].bal + 1, a[i].bal));
  while (!q.empty()) {
    team t = q.top();
    if (t.need > bal) break;
    q.pop();
    bal -= t.need;
    now--;
    while (r <= n && a[r].bal > bal)
      q.push(team(a[r].w - a[r].bal + 1, a[r].w)), r++, now++;
    ans = min(ans, now);
  }
  printf("%d\n", ans);
  return 0;
}
