#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> t[300005];
int n;
priority_queue<long long> q;
bool can(int p) {
  while (!q.empty()) q.pop();
  int l;
  for (l = 1; l < n && -t[l].first > -t[0].first; l++)
    ;
  if (l - 1 <= p) return true;
  int c = l - 1;
  for (int i = 1, to = l; i < to; ++i) q.push(-(t[i].second - (-t[i].first)));
  long long w = -t[0].first;
  while (c > p) {
    if (q.empty()) return false;
    long long z = -q.top();
    q.pop();
    if (z >= w) return false;
    w -= z + 1;
    c--;
    while (l < n && -t[l].first > w) {
      c++;
      q.push(-(t[l].second - (-t[l].first)));
      l++;
    }
  }
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 0, to = n; i < to; ++i) {
    long long a, b;
    scanf("%I64d%I64d", &a, &b);
    t[i] = make_pair(-a, b);
  }
  sort(t + 1, t + n);
  int s = 0, e = n;
  while (e - s > 1) {
    int m = (s + e) / 2;
    if (can(m - 1))
      e = m;
    else
      s = m;
  }
  printf("%d\n", s + 1);
  return 0;
}
