#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 3e5 + 10;
vector<pair<long long, long long> > a;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  priority_queue<long long> s;
  int n;
  cin >> n;
  if (n == 1) {
    cout << 1;
    return 0;
  }
  a.resize(n - 1);
  long long our;
  long long tmp;
  cin >> our >> tmp;
  n -= 1;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
    a[i].second = a[i].second - a[i].first + 1;
  }
  sort(a.begin(), a.end());
  if (our >= a[n - 1].first) {
    cout << 1;
    return 0;
  }
  int ind = n - 1;
  int ans = 1e9 + 1;
  while ((ind >= 0) && (our < a[ind].first)) {
    s.push(-a[ind].second);
    ind--;
  }
  while ((ind == n - 1) || ((s.size() > 0) && (our >= 0))) {
    ans = min(ans, (int)s.size() + 1);
    our += s.top();
    s.pop();
    while ((ind >= 0) && (our < a[ind].first)) {
      s.push(-a[ind].second);
      ind--;
    }
  }
  if (our >= 0) {
    ans = min(ans, (int)s.size() + 1);
  }
  cout << ans;
}
