#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 10;
long long t[MAXN], x, y, w[MAXN];
set<pair<long long, long long> > s, c;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  cin >> x >> y;
  n--;
  for (int i = 0; i < n; i++) cin >> t[i] >> w[i];
  for (int i = 0; i < n; i++)
    if (t[i] > x)
      s.insert({w[i] - t[i] + 1, i});
    else
      c.insert({-t[i], i});
  int ans = s.size() + 1;
  while (x > 0 and s.size() > 0) {
    pair<long long, long long> p = *s.begin();
    if (p.first <= x) {
      x -= p.first;
      s.erase(s.begin());
      while (c.size() > 0) {
        int ind = c.begin()->second;
        if (t[ind] <= x) break;
        s.insert({1 + w[ind] - t[ind], ind});
        c.erase(c.begin());
      }
      ans = min(ans, (int)s.size() + 1);
    } else
      break;
  }
  cout << ans << endl;
  return 0;
}
