#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  long long int n;
  cin >> n;
  long long int t[n];
  long long int w[n];
  multiset<pair<long long int, long long int>,
           greater<pair<long long int, long long int>>>
      s1;
  multiset<long long int> s2;
  long long int a, b;
  cin >> a >> b;
  long long int ans = -1;
  for (int i = 1; i < n; i++) {
    long long int a1, b1;
    cin >> a1 >> b1;
    if (a1 > a) {
      s2.insert(b1 - a1 + 1);
    } else {
      s1.insert(make_pair(a1, b1));
    }
  }
  ans = s2.size() + 1;
  while (s2.size() > 0) {
    long long int req = *(s2.begin());
    if (req > a) break;
    s2.erase(s2.begin());
    a = a - req;
    while (s1.size() > 0) {
      auto itr = s1.begin();
      long long int x1 = itr->first;
      if (x1 <= a) break;
      s2.insert(itr->second - itr->first + 1);
      s1.erase(itr);
    }
    long long int sz = s2.size();
    ans = min(ans, sz + 1);
  }
  cout << ans << "\n";
  return 0;
}
