#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5;
const long long int inf64 = 1e18 + 5;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, i;
  pair<long long int, long long int> fr;
  cin >> n;
  vector<pair<long long int, long long int> > v;
  cin >> fr.first >> fr.second;
  for (i = 0; i < n - 1; i++) {
    long long int a, b;
    cin >> a >> b;
    v.push_back({a, b});
  }
  sort(v.begin(), v.end(), greater<pair<long long int, long long int> >());
  int ans = 0;
  for (i = 0; i < n - 1; i++) {
    if (v[i].first <= fr.first) break;
    ++ans;
  }
  priority_queue<long long int, vector<long long int>, greater<long long int> >
      pq;
  for (int i = 0, j = 0; i < v.size(); i = j) {
    while (j < v.size() && v[j].first > fr.first) {
      pq.push(v[j].second - v[j].first + 1);
      ++j;
    }
    if (pq.empty()) break;
    ans = min(ans, (int)pq.size());
    long long int p = pq.top();
    if (p > fr.first) break;
    pq.pop();
    fr.first -= p;
  }
  ans = min(ans, (int)pq.size());
  while (!pq.empty() && fr.first >= pq.top()) {
    fr.first -= pq.top();
    pq.pop();
    ans = min(ans, (int)pq.size());
  }
  cout << ans + 1;
}
