#include <bits/stdc++.h>
using namespace std;
struct Team {
  long long t;
  long long w;
  int id;
  bool operator<(const Team& other) const { return w - t < other.w - other.t; }
};
multiset<Team> better;
Team teams[300001];
bool cmp(const Team& a, const Team& b) {
  if (a.t != b.t) {
    return a.t > b.t;
  } else {
    return a.id < b.id;
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> teams[i].t >> teams[i].w;
    teams[i].id = i;
  }
  sort(teams, teams + n, cmp);
  int cur_pos;
  long long balloons;
  for (int i = 0; i < n; i++) {
    if (teams[i].id == 0) {
      cur_pos = i;
      balloons = teams[i].t;
      break;
    }
    better.insert(teams[i]);
  }
  int best_pos = better.size() + 1;
  while (balloons > 0 && better.size() > 0) {
    long long need = better.begin()->w - better.begin()->t + 1;
    if (balloons < need) break;
    balloons -= need;
    better.erase(better.begin());
    while (cur_pos + 1 < n && teams[cur_pos + 1].t > balloons) {
      better.insert(teams[cur_pos + 1]);
      cur_pos++;
    }
    best_pos = min((int)better.size() + 1, best_pos);
  }
  cout << best_pos << endl;
  return 0;
}
