#include <bits/stdc++.h>
using namespace std;
struct IO {
  char buf[(1 << 20)], *p1, *p2;
  char pbuf[(1 << 20)], *pp;
  IO() : p1(buf), p2(buf), pp(pbuf) {}
  inline char gc() {
    return getchar();
    if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, (1 << 20), stdin);
    return p1 == p2 ? ' ' : *p1++;
  }
  inline bool blank(char ch) {
    return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
  }
  template <class T>
  inline void read(T &x) {
    register double tmp = 1;
    register bool sign = 0;
    x = 0;
    register char ch = gc();
    for (; !(ch >= '0' && ch <= '9'); ch = gc())
      if (ch == '-') sign = 1;
    for (; (ch >= '0' && ch <= '9'); ch = gc()) x = x * 10 + (ch - '0');
    if (ch == '.')
      for (ch = gc(); (ch >= '0' && ch <= '9'); ch = gc())
        tmp /= 10.0, x += tmp * (ch - '0');
    if (sign) x = -x;
  }
  inline void read(char *s) {
    register char ch = gc();
    for (; blank(ch); ch = gc())
      ;
    for (; !blank(ch); ch = gc()) *s++ = ch;
    *s = 0;
  }
  inline void read(char &c) {
    for (c = gc(); blank(c); c = gc())
      ;
  }
  template <class t>
  inline void write(t x) {
    if (x < 0)
      putchar('-'), write(-x);
    else {
      if (x > 9) write(x / 10);
      putchar('0' + x % 10);
    }
  }
} io;
const long long mo = 1e9 + 7;
const long long Mo = 998244353;
const long long N = 3e5 + 5;
priority_queue<long long, vector<long long>, greater<long long> > q;
long long n, m, ans, rk = 1e9;
struct Node {
  long long t, w, id;
  inline bool friend operator<(const Node &s, const Node &t) {
    return s.t > t.t;
  }
};
Node a[N];
signed main() {
  io.read(n);
  long long myt, myw;
  io.read(myt), io.read(myw);
  n--;
  for (long long i = (1); i <= (n); i++)
    io.read(a[i].t), io.read(a[i].w), a[i].id = i;
  sort(a + 1, a + n + 1);
  long long j = 1;
  for (;;) {
    while (j <= n && a[j].t > myt) q.push(max(0ll, a[j].w - a[j].t + 1)), j++;
    rk = min(rk, (long long)q.size() + 1);
    if (q.size() && (q.top() <= myt))
      myt -= q.top(), q.pop();
    else
      return printf("%lld\n", rk), 0;
  }
  return 0;
}
