#include <bits/stdc++.h>
using namespace std;
int n, m;
long long int t, w, lj, lk;
priority_queue<long long int> a;
priority_queue<pair<long long int, long long int> > b;
void up() {
  while (b.size()) {
    pair<long long int, long long int> c = b.top();
    if (c.first <= t) break;
    a.push(c.first - c.second - 1);
    b.pop();
  }
  int c = a.size();
  m = min(m, c + 1);
}
int main() {
  scanf("%d", &n);
  scanf("%I64d%I64d", &t, &w);
  for (int i = 1; i < n; i++) {
    scanf("%I64d%I64d", &lj, &lk);
    b.push(make_pair(lj, lk));
  }
  m = n;
  up();
  while (a.size() && t > 0) {
    long long int c = a.top();
    if (t + c >= 0) {
      a.pop();
      t += c;
      up();
    } else {
      break;
    }
  }
  printf("%d\n", m);
  return 0;
}
