#include <bits/stdc++.h>
using namespace std;
const long long UNDEF = -1;
const long long INF = 1e18;
template <typename T>
inline bool chkmax(T& aa, T bb) {
  return aa < bb ? aa = bb, true : false;
}
template <typename T>
inline bool chkmin(T& aa, T bb) {
  return aa > bb ? aa = bb, true : false;
}
struct debugger {
  template <typename T>
  debugger& operator,(const T& v) {
    cerr << v << " ";
    return *this;
  }
} dbg;
const long long mn = 3e5 + 4;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  scanf("%lld", &n);
  long long lt, lw;
  scanf("%lld%lld", &lt, &lw);
  priority_queue<pair<long long, long long> > lesser;
  priority_queue<long long, vector<long long>, greater<long long> > greater;
  for (long long i = 1; i < n; i++) {
    long long t, w;
    scanf("%lld%lld", &t, &w);
    if (t <= lt)
      lesser.push(make_pair(t, w));
    else
      greater.push(w - t + 1);
  }
  long long final = INF;
  for (long long k = 0; k <= n; k++) {
    long long gsz = greater.size();
    chkmin(final, gsz);
    if (gsz > 0) {
      long long g = greater.top();
      greater.pop();
      lt -= g;
      if (lt < 0) break;
      while (!lesser.empty()) {
        pair<long long, long long> x = lesser.top();
        long long xt = x.first, xw = x.second;
        if (x.first > lt) {
          lesser.pop();
          greater.push(xw - xt + 1);
        } else
          break;
      }
    } else
      break;
  }
  final++;
  printf("%lld\n", final);
}
