#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int maxn = 300000 + 50;
int n, ans = inf, tmp, cut, rk;
long long now;
int id[maxn];
long long w[maxn], num[maxn];
priority_queue<long long, vector<long long>, greater<long long> > q;
bool cmp(const int &x, const int &y) { return num[x] > num[y]; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld%lld", &num[i], &w[i]);
    id[i] = i;
  }
  now = num[1];
  sort(id + 1, id + n + 1, cmp);
  tmp = 1;
  for (;; tmp++) {
    if (num[id[tmp]] == now) break;
    q.push(w[id[tmp]] - num[id[tmp]] + 1);
  }
  rk = tmp;
  ans = min(ans, rk);
  tmp++;
  while (1) {
    if (q.empty()) break;
    now -= q.top();
    q.pop();
    rk--;
    if (now < 0) break;
    for (;; tmp++) {
      if (num[id[tmp]] <= now) break;
      q.push(w[id[tmp]] - num[id[tmp]] + 1);
      rk++;
    }
    ans = min(ans, rk);
  }
  printf("%d", ans);
  return 0;
}
