#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
struct teamNode {
  long long ti, wi, wt;
} team[maxn];
bool compare(const teamNode &a, const teamNode &b) { return a.ti > b.ti; }
priority_queue<long long, vector<long long>, greater<long long> > q;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld%lld", &team[i].ti, &team[i].wi);
    team[i].wt = team[i].wi - team[i].ti + 1;
  }
  sort(team + 1, team + n, compare);
  int idx = 1;
  while (idx < n && team[idx].ti > team[0].ti) q.push(team[idx++].wt);
  int ans = q.size() + 1;
  while (!q.empty() && team[0].ti >= q.top()) {
    team[0].ti -= q.top();
    q.pop();
    while (idx < n && team[idx].ti > team[0].ti) q.push(team[idx++].wt);
    if (q.size() + 1 < ans) ans = q.size() + 1;
  }
  printf("%d", ans);
  return 0;
}
