#include <bits/stdc++.h>
using namespace std;
struct team {
  long long t, w;
} a[300010];
bool cmp1(struct team x, struct team y) { return (x.t > y.t); }
struct cmp {
  bool operator()(long long x, long long y) { return x > y; }
};
int n;
priority_queue<long long, vector<long long>, cmp> q;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  int res = 1;
  for (int i = 1; i < n + 1; i++) {
    cin >> a[i].t >> a[i].w;
    if (a[i].t > a[1].t) res++;
  }
  sort(a + 2, a + n + 1, cmp1);
  int i = 2;
  while (i <= n) {
    int j = i;
    while (j <= n && a[j].t > a[1].t) {
      q.push(a[j].w - a[j].t);
      j++;
    }
    if (j == i) break;
    while (!q.empty()) {
      if (q.top() > a[1].t) break;
      a[1].t -= (q.top() + 1);
      q.pop();
      while (j <= n && a[j].t > a[1].t) {
        q.push(a[j].w - a[j].t);
        j++;
      }
      if (res > q.size() + 1) res = q.size() + 1;
    }
    i = j;
  }
  cout << res;
  return 0;
}
