#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<long long, long long> > small;
priority_queue<long long, vector<long long>, greater<long long> > big;
long long v, w, v1, w1;
int n, pos;
int main() {
  while (scanf("%d", &n) != EOF) {
    scanf("%I64d%I64d", &v, &w);
    for (int i = 1; i < n; ++i) {
      scanf("%I64d%I64d", &v1, &w1);
      if (v1 <= v)
        small.push(pair<long long, long long>(v1, w1));
      else
        big.push(w1 - v1 + 1);
    }
    pos = big.size() + 1;
    while (!big.empty()) {
      if (v < big.top()) break;
      v -= big.top();
      big.pop();
      while (!small.empty()) {
        if (small.top().first <= v) break;
        big.push(small.top().second - small.top().first + 1);
        small.pop();
      }
      if (pos > big.size() + 1) pos = big.size() + 1;
    }
    cout << pos << endl;
  }
  return 0;
}
