#include <bits/stdc++.h>
using namespace std;
const int N = 300001;
struct team {
  long long t, w, wa;
  team(long long t = 0, long long w = 0) : t(t), w(w) { wa = w - t + 1; }
  bool operator<(const team &r) const { return r.wa < wa; }
} a[N];
bool cmp(team x, team y) { return x.t > y.t; }
priority_queue<team> q;
int main() {
  int n, i, j;
  long long ans, a1;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) scanf("%lld%lld", &a[i].t, &a[i].w);
  sort(a + 1, a + n, cmp);
  for (i = 1; i < n; ++i) {
    if (a[i].t > a[0].t)
      q.push(team(a[i].t, a[i].w));
    else
      break;
  }
  a1 = ans = i;
  while (!q.empty()) {
    team tt = q.top();
    q.pop();
    a[0].t -= tt.wa;
    if (a[0].t < 0) break;
    for (j = i; j < n; ++j) {
      if (a[j].t > a[0].t) {
        q.push(team(a[j].t, a[j].w));
      } else
        break;
    }
    a1 += j - i - 1;
    i = j;
    ans = min(ans, a1);
  }
  printf("%lld\n", ans);
  return 0;
}
