#include <bits/stdc++.h>
using namespace std;
long n, p, m, d;
struct cmp {
  bool operator()(const long long& l, const long long& r) { return l > r; }
};
priority_queue<long long, vector<long long>, cmp> t;
pair<long long, long long> a[300300];
int main() {
  cin >> n;
  for (long i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
  sort(a + 1, a + n);
  p = n - 1;
  m = n;
  d = 0;
  while (a[0].first < a[p].first && p > 0) {
    t.push(a[p].second - a[p].first);
    p--;
  }
  m = min(n - p - d, m);
  do {
    if (m == 1) break;
    long long q = t.top();
    if (q < a[0].first) {
      a[0].first -= q + 1;
      t.pop();
    } else
      break;
    d++;
    while (a[0].first < a[p].first && p > 0) {
      t.push(a[p].second - a[p].first);
      p--;
    }
    m = min(n - p - d, m);
  } while (!t.empty());
  cout << m;
}
