#include <bits/stdc++.h>
using namespace std;
inline void read(int &n) {
  n = 0;
  register bool neg = false;
  register char c = getchar_unlocked();
  if (c == EOF) {
    n = -1;
    return;
  }
  while (!('0' <= c && c <= '9')) {
    if (c == '-') neg = true;
    c = getchar_unlocked();
  }
  while ('0' <= c && c <= '9') {
    n = n * 10 + c - '0';
    c = getchar_unlocked();
  }
  n = (neg ? (-n) : (n));
}
inline void writeInt(int n) {
  register int idx = 20;
  if (n < 0) putchar_unlocked('-');
  n = abs(n);
  char out[21];
  out[20] = ' ';
  do {
    idx--;
    out[idx] = n % 10 + '0';
    n /= 10;
  } while (n);
  do {
    putchar_unlocked(out[idx++]);
  } while (out[idx] != ' ');
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  long long a, b, c, d;
  cin >> n;
  cin >> a >> b;
  vector<pair<long long, long long> > vet;
  priority_queue<pair<long long, long long> > lo;
  priority_queue<long long> hi;
  for (int i = 1; i < n; i++) {
    cin >> c >> d;
    vet.push_back(make_pair(c, d));
    if (c > a)
      hi.push(-((d - c) + 1));
    else
      lo.push(make_pair(c, d));
  }
  int ans = hi.size() + 1;
  while (!hi.empty() && a > 0LL) {
    long long at = -hi.top();
    if (at > a) break;
    hi.pop();
    a -= at;
    while (!lo.empty() && a < lo.top().first) {
      hi.push(-((lo.top().second - lo.top().first) + 1));
      lo.pop();
    }
    ans = min(ans, int(hi.size()) + 1);
  }
  cout << ans << '\n';
  return 0;
}
