#include <bits/stdc++.h>
using namespace std;
const long long modn = 1000000007;
inline long long mod(long long x) { return x % modn; }
int n;
const int N = 312345;
long long t[N], w[N];
int main() {
  int i, j;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%lld %lld", &t[i], &w[i]);
  int cur = 1;
  multiset<long long> kill;
  multiset<pair<long long, long long> > ot;
  for (i = 1; i < n; i++)
    if (t[i] > t[0]) {
      cur++;
      kill.insert(w[i] - t[i] + 1ll);
    } else
      ot.insert(pair<long long, long long>(t[i], w[i]));
  kill.insert(1.5e18);
  ot.insert(pair<long long, long long>(-1.5e18, -1));
  int best = cur;
  while (t[0] > 0) {
    long long nxkill = *kill.begin();
    long long nxrise = t[0] - ot.rbegin()->first + 1;
    if (nxkill > t[0]) break;
    if (nxkill <= nxrise) {
      t[0] -= nxkill;
      cur--;
      kill.erase(kill.begin());
      assert(!kill.empty());
    } else {
      t[0] -= nxrise;
      kill.erase(kill.begin());
      kill.insert(nxkill - nxrise);
    }
    while (ot.rbegin()->first > t[0]) {
      cur++;
      pair<long long, long long> p = *ot.rbegin();
      ot.erase(ot.find(p));
      kill.insert(p.second - p.first + 1ll);
    }
    best = min(best, cur);
  }
  printf("%d\n", best);
}
