#include <bits/stdc++.h>
using namespace std;
const int N = 300100;
int n;
pair<long long, long long> a[N];
set<pair<long long, long long> > s;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%I64d%I64d", &a[i].first, &a[i].second);
  long long bl = a[0].first, wlim = a[0].second;
  sort(a, a + n, greater<pair<long long, long long> >());
  int ptr = 0;
  while (ptr < n) {
    if (a[ptr].first == bl) break;
    ++ptr;
  }
  int rnk = ptr;
  for (int j = ptr; j < n; j++)
    if (a[j].first == bl && a[j].second == wlim) {
      swap(a[j], a[ptr]);
      break;
    }
  int ans = rnk;
  for (int i = 0; i < ptr; i++)
    s.insert(pair<long long, long long>(a[i].second - a[i].first + 1LL, i));
  long long need;
  ++ptr;
  while ((int)s.size()) {
    need = s.begin()->first;
    if (need > bl) break;
    s.erase(s.begin());
    bl -= need;
    rnk--;
    while (ptr < n) {
      if (a[ptr].first > bl) {
        s.insert(pair<long long, long long>(a[ptr].second - a[ptr].first + 1LL,
                                            ptr));
        rnk++;
      } else
        break;
      ptr++;
    }
    ans = min(ans, rnk);
  }
  printf("%d\n", ans + 1);
  return 0;
}
