#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAXN = 301010;
int main() {
  int n;
  scanf("%d", &n);
  ll ourT, ourW;
  scanf("%I64d%I64d", &ourT, &ourW);
  multiset<pair<ll, ll> > worse;
  ll x, y;
  for (int i = 0; i < n - 1; ++i) {
    scanf("%I64d%I64d", &x, &y);
    worse.insert({x, y});
  }
  multiset<ll> better;
  while (!worse.empty() && (--worse.end())->first > ourT) {
    auto it = --worse.end();
    better.insert(it->second - it->first + 1);
    worse.erase(it);
  }
  int ans = better.size();
  while (!better.empty()) {
    if (*better.begin() <= ourT) {
      ourT -= *better.begin();
      better.erase(better.begin());
      while (!worse.empty() && (--worse.end())->first > ourT) {
        auto it = --worse.end();
        better.insert(it->second - it->first + 1);
        worse.erase(it);
      }
    } else {
      break;
    }
    ans = min(ans, (int)better.size());
  }
  cout << ans + 1 << '\n';
  return 0;
}
