#include <bits/stdc++.h>
using namespace std;
priority_queue<long long, vector<long long>, greater<long long>> pq;
vector<pair<long long, long long>> v;
int n, vec_size;
long long cur_t, cur_w;
int main(int argc, char *argv[]) {
  scanf("%d", &n);
  scanf("%I64d%I64d", &cur_t, &cur_w);
  for (int i = 1; i < n; ++i) {
    long long t, w;
    scanf("%I64d%I64d", &t, &w);
    if (t > cur_t) {
      pq.push(w - t + 1);
    } else {
      v.push_back(make_pair(t, w));
      vec_size++;
    }
  }
  sort(v.begin(), v.end());
  int ans = pq.size() + 1;
  while (pq.size() > 0 && pq.top() <= cur_t) {
    cur_t -= pq.top();
    pq.pop();
    while (vec_size > 0 && v.back().first > cur_t) {
      pq.push(v.back().second - v.back().first + 1);
      v.pop_back();
      vec_size--;
    }
    ans = min(ans, (int)(pq.size() + 1));
  }
  printf("%d\n", ans);
  return 0;
}
