#include <bits/stdc++.h>
using namespace std;
long long n, Ans, now, A, B, a[1000005], b[1000005];
inline long long read() {
  long long ret = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch <= '9' && ch >= '0') ret = ret * 10 + ch - '0', ch = getchar();
  return ret;
}
namespace heap1 {
long long heap[1000005], tot, Now, Son;
inline void put(long long x) {
  heap[Now = ++tot] = x;
  while (Now > 1 && heap[Now] < heap[Now >> 1])
    swap(heap[Now], heap[Now >> 1]), Now >>= 1;
}
inline void pop() {
  heap[1] = heap[tot--];
  Now = 1, Son = 2;
  while (Son <= tot) {
    if (Son < tot && heap[Son + 1] < heap[Son]) Son++;
    if (heap[Son] < heap[Now])
      swap(heap[Son], heap[Now]), Now = Son, Son = Now << 1;
    else
      break;
  }
}
}  // namespace heap1
namespace heap2 {
long long heap[1000005], tot, Now, Son, id[1000005];
inline void Swap(long long x, long long y) {
  swap(heap[x], heap[y]), swap(id[x], id[y]);
}
inline void put(long long x, long long Id) {
  heap[Now = ++tot] = x, id[tot] = Id;
  while (Now > 1 && heap[Now] > heap[Now >> 1]) Swap(Now, Now >> 1), Now >>= 1;
}
inline void pop() {
  id[1] = id[tot], heap[1] = heap[tot--];
  Now = 1, Son = 2;
  while (Son <= tot) {
    if (Son < tot && heap[Son + 1] > heap[Son]) Son++;
    if (heap[Son] > heap[Now])
      Swap(Son, Now), Now = Son, Son = Now << 1;
    else
      break;
  }
}
}  // namespace heap2
signed main() {
  n = read() - 1;
  A = read(), B = read();
  for (long long i = 1; i <= n; i++) {
    a[i] = read(), b[i] = read();
    if (a[i] > A)
      heap1::put(b[i] - a[i] + 1);
    else
      heap2::put(a[i], i);
  }
  Ans = heap1::tot;
  for (;;) {
    if (!heap1::tot) break;
    long long Now = heap1::heap[1];
    if (A < Now) break;
    heap1::pop();
    A -= Now;
    while (heap2::tot && heap2::heap[1] > A)
      heap1::put(b[heap2::id[1]] - a[heap2::id[1]] + 1), heap2::pop();
    Ans = min(Ans, heap1::tot);
  }
  printf("%d", Ans + 1);
  return 0;
}
