#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f3f3f3f3f3f3f;
const double pi = 3.141592653589793;
const double inf = 1e18;
const double eps = 1e-8;
const long long mod = 1e18;
const unsigned long long mx = 133333331;
int n;
struct team {
  long long t, w;
} teams[300005];
bool cmp(const struct team a, const struct team b) { return a.t < b.t; }
struct cmp1 {
  bool operator()(const struct team a, const struct team b) {
    return a.w - a.t > b.w - b.t;
  }
};
priority_queue<struct team, vector<struct team>, cmp1> q;
int main() {
  cin >> n;
  n--;
  long long t, w;
  cin >> t >> w;
  for (int i = 0; i < n; i++) {
    scanf("%lld %lld", &teams[i].t, &teams[i].w);
  }
  sort(teams, teams + n, cmp);
  int cnt = 0;
  while (cnt < n && t >= teams[cnt].t) cnt++;
  for (int i = cnt; i < n; i++) q.push(teams[i]);
  int Min = n - cnt + 1;
  while (!q.empty()) {
    struct team temp = q.top();
    if (t >= temp.w - temp.t) {
      t -= (temp.w - temp.t + 1);
      q.pop();
      n--;
      while (cnt > 0 && t < teams[cnt - 1].t) {
        q.push(teams[cnt - 1]);
        cnt--;
      }
      Min = min(Min, n - cnt + 1);
    } else
      break;
  }
  cout << Min << endl;
  return 0;
}
