#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long n, first, second, pos(0), best;
  cin >> n;
  vector<pair<unsigned long long, unsigned long long>> v(n);
  for (int i = 0; i < n; ++i) cin >> v[i].first >> v[i].second;
  first = v[0].first;
  second = v[0].second;
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  unsigned long long ind;
  for (int i = 0; i < n; ++i)
    if (v[i].first == first) {
      ind = i;
      v.erase(v.begin() + i);
      break;
    }
  n = v.size();
  unsigned long long sum = first;
  unsigned long long ans = ind;
  unsigned long long now = ind;
  multiset<unsigned long long> plus;
  for (int i = 0; i < ans; ++i) plus.insert(v[i].second - v[i].first + 1);
  while (!plus.empty()) {
    unsigned long long need = *plus.begin();
    if (sum < need) break;
    sum -= need;
    --now;
    plus.erase(plus.begin());
    for (; ind < n; ++ind) {
      if (sum >= v[ind].first) break;
      need = v[ind].second - v[ind].first + 1;
      plus.insert(need);
      ++now;
    }
    ans = min(ans, now);
  }
  cout << ans + 1;
  return 0;
}
