#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  char c = getchar();
  long long tot = 1;
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') {
    tot = -1;
    c = getchar();
  }
  long long sum = 0;
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum * tot;
}
inline void wr(long long x) {
  if (x < 0) {
    putchar('-');
    wr(-x);
    return;
  }
  if (x >= 10) wr(x / 10);
  putchar(x % 10 + '0');
}
inline void wrn(long long x) {
  wr(x);
  putchar('\n');
}
inline void wri(long long x) {
  wr(x);
  putchar(' ');
}
inline void wrn(long long x, long long y) {
  wri(x);
  wrn(y);
}
inline void wrn(long long a, long long b, long long c) {
  wri(a);
  wrn(b, c);
}
long long n, m, ans, tot, num, t, a, b;
pair<long long, long long> z[300005];
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  return (a.first == b.first) ? a.second < b.second : a.first > b.first;
}
priority_queue<long long, vector<long long>, greater<long long> > q;
signed main() {
  n = read();
  for (long long i = (1); i <= (n); i++)
    a = read(), b = read(), z[i] = make_pair(a, b);
  sort(z + 2, z + n + 1, cmp);
  long long tot = 2;
  ans = 1000000005;
  while (1) {
    while (z[tot].first > z[1].first && tot <= n)
      q.push(z[tot].second - z[tot].first + 1), tot++;
    ans = min(ans, tot - 1 - num);
    if (q.empty()) break;
    t = q.top();
    if (z[1].first < t) break;
    num++;
    z[1].first -= t;
    q.pop();
  }
  wrn(ans);
  return 0;
}
