#include <bits/stdc++.h>
using namespace std;
char *fs, *ft, buf[1 << 15];
inline char getc() {
  return (fs == ft &&
          (ft = (fs = buf) + fread(buf, 1, 1 << 15, stdin), fs == ft))
             ? 0
             : *fs++;
}
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int MAXN = 300010;
int n, ans = 1000000000, flag = 1, top;
long long sum;
struct wy {
  long long p, w;
  long long c;
} t[MAXN];
priority_queue<long long> q;
inline long long cmp(wy a, wy b) { return a.p > b.p; }
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) {
    long long x = read(), y = read();
    if (i == 1) sum = x;
    if (i != 1) t[++top] = (wy){x, y, y - x + 1};
  }
  sort(t + 1, t + 1 + top, cmp);
  while (flag <= top) {
    if (t[flag].p > sum)
      q.push(-t[flag].c);
    else
      break;
    ++flag;
  }
  ans = ((ans) > (q.size() + 1) ? (q.size() + 1) : (ans));
  while (q.size()) {
    ans = ((ans) > (q.size() + 1) ? (q.size() + 1) : (ans));
    if (sum < -q.top()) break;
    sum += q.top();
    q.pop();
    while (flag <= top) {
      if (t[flag].p > sum)
        q.push(-t[flag].c);
      else
        break;
      ++flag;
    }
  }
  ans = ((ans) > (q.size() + 1) ? (q.size() + 1) : (ans));
  printf("%d\n", ans);
  return 0;
}
