#include <bits/stdc++.h>
using namespace std;
struct node {
  long long t, w;
  bool operator<(const node &a) const { return a.w - a.t < w - t; }
} fly[300005];
priority_queue<node> q;
long long n, ans;
bool cmp(node x, node y) { return x.t > y.t; }
int main() {
  long long ans = 0, n;
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) cin >> fly[i].t >> fly[i].w;
  sort(fly + 2, fly + 1 + n, cmp);
  for (int id = 2, tot = 0;;) {
    while (fly[id].t > fly[1].t && id <= n) q.push(fly[id++]);
    ans = max(ans, n - id + 1 + tot);
    if (!q.empty() && q.top().w - q.top().t + 1 <= fly[1].t)
      fly[1].t -= q.top().w - q.top().t + 1, q.pop(), tot++;
    else
      break;
  }
  cout << n - ans;
  return 0;
}
