#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <typename T>
T pow(T a, T b, long long m) {
  T ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans % m;
}
int main() {
  long long n;
  cin >> n;
  vector<pair<long long, long long> > v(n);
  long long a, b;
  for (long long i = 0; i < n; i++) {
    cin >> v[i].first;
    cin >> v[i].second;
  }
  a = v[0].first;
  b = v[0].second;
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> > >
      pq;
  multiset<long long> s;
  for (long long i = 1; i < n; i++) {
    if (v[i].first <= a) {
      pq.push(v[i]);
    } else {
      s.insert(v[i].second - v[i].first + 1);
    }
  }
  long long have = 0;
  long long rank = s.size() + 1;
  long long cur = 0;
  while (a > 0 && pq.size() > 0) {
    pair<long long, long long> p = pq.top();
    while (p.first == a) {
      s.insert(p.second - p.first + 1);
      pq.pop();
      if (pq.size() == 0) break;
      p = pq.top();
    }
    p = pq.top();
    have += a - p.first;
    a = p.first;
    while (s.size() > 0) {
      long long req2 = *(s.begin());
      if (req2 > have) {
        break;
      }
      have -= req2;
      s.erase(s.begin());
    }
    long long sz = s.size();
    rank = min(rank, sz + 1);
  }
  if (pq.size() == 0) {
    have = a;
    while (s.size() > 0) {
      long long req2 = *(s.begin());
      if (req2 > have) {
        break;
      }
      have -= req2;
      s.erase(s.begin());
    }
    long long sz = s.size();
    rank = min(rank, sz + 1);
  }
  cerr << "a"
       << ": " << a << "\n";
  cout << rank;
  return 0;
}
