#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) {
  if (a > b)
    return a;
  else
    return b;
}
long long min(long long a, long long b) {
  if (a < b)
    return a;
  else
    return b;
}
long long stoi(string &str) {
  istringstream ss(str);
  long long i;
  ss >> i;
  return i;
}
const int MX = 305005;
long long t, w, LimakTotal, LimakBallons, LimakWeight;
pair<long long, long long> E[MX];
long long n, mn = MX, MovePtr;
multiset<long long> Ballons;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  cin >> t >> w;
  LimakBallons = t;
  LimakWeight = w;
  n--;
  for (int i = 0; i < n; i++) {
    cin >> t >> w;
    E[i] = {t, w};
  }
  sort(E, E + n);
  reverse(E, E + n);
  for (; MovePtr < n; MovePtr++) {
    t = E[MovePtr].first;
    w = E[MovePtr].second;
    if (t > LimakBallons)
      Ballons.insert(w - t + 1);
    else
      break;
  }
  mn = Ballons.size() + 1;
  while (!Ballons.empty() && *Ballons.begin() <= LimakBallons) {
    auto it = Ballons.begin();
    long long BestOption = *it;
    LimakBallons -= BestOption;
    Ballons.erase(it);
    for (; MovePtr < n; MovePtr++) {
      t = E[MovePtr].first;
      w = E[MovePtr].second;
      if (t > LimakBallons)
        Ballons.insert(w - t + 1);
      else
        break;
    }
    mn = min(mn, Ballons.size() + 1);
  }
  cout << mn << "\n";
  return 0;
}
