#include <bits/stdc++.h>
using namespace std;
const int maxn = 300005;
using ll = long long;
pair<ll, ll> p[maxn];
int main(int argc, char const *argv[]) {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%lld %lld", &p[i].first, &p[i].second);
  }
  multiset<ll> big;
  multiset<pair<ll, ll>> small;
  for (int i = 2; i <= n; ++i) {
    if (p[i].second < p[i].first) continue;
    if (p[i].first > p[1].first) {
      big.insert(p[i].second + 1 - p[i].first);
    } else {
      small.insert({p[i].first, p[i].second + 1 - p[i].first});
    }
  }
  int ans = big.size() + 1;
  while (1) {
    if (big.empty()) {
      cout << "1" << endl;
      return 0;
    }
    ans = min(ans, (int)big.size() + 1);
    multiset<ll>::iterator itr = big.begin();
    if (*itr > p[1].first) break;
    p[1].first -= *itr;
    big.erase(itr);
    while (!small.empty() && small.rbegin()->first > p[1].first) {
      big.insert(small.rbegin()->second);
      small.erase(--small.end());
    }
  }
  cout << ans << endl;
  return 0;
}
