#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
struct node {
  long long weight, t;
  node() {}
  node(long long tt, long long dd) : t(tt), weight(dd) {}
  bool operator<(const node &a) const { return weight > a.weight; }
} a[maxn];
bool cmp(node a, node b) { return a.t > b.t; }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%I64d%I64d", &a[i].t, &a[i].weight);
    a[i].weight = a[i].weight - a[i].t + 1;
  }
  sort(a + 1, a + n, cmp);
  int ok = 1, index = 1, s = 1, ans = maxn;
  priority_queue<node> pq;
  while (ok) {
    ok = 0;
    while (s < n && a[s].t > a[0].t) pq.push(a[s++]), index++;
    ans = min(ans, index);
    if (!pq.empty()) {
      a[0].t -= pq.top().weight;
      pq.pop();
      if (a[0].t < 0) break;
      ok = 1;
      index--;
    }
  }
  printf("%d\n", ans);
  return 0;
}
