#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
long long t[N], w[N];
bool comp(int a, int b) { return t[a] > t[b]; }
int main() {
  int n;
  vector<int> r;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld %lld", t + i, w + i);
    if (i) r.push_back(i);
  }
  sort(r.begin(), r.end(), comp);
  int myrank = 0;
  priority_queue<long long, vector<long long>, greater<long long> > q;
  int p = 0;
  while (p < n - 1 and t[r[p]] > t[0]) {
    q.push(w[r[p]] - t[r[p]] + 1);
    myrank++;
    p++;
  }
  int ans = myrank;
  long long b = 0;
  long long myt = t[0];
  while (myt) {
    while (p < n - 1 and t[r[p]] == myt) {
      q.push(w[r[p]] - t[r[p]] + 1);
      myrank++;
      p++;
    }
    if (p < n - 1) {
      b += myt - t[r[p]];
      myt = t[r[p]];
    } else {
      b += myt;
      myt = 0;
    }
    while (!q.empty() and b >= q.top()) {
      b -= q.top();
      myrank--;
      q.pop();
    }
    ans = min(ans, myrank);
  }
  printf("%d\n", ans + 1);
  return 0;
}
