#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5;
int n;
pair<long long, long long> a[MAXN + 5];
priority_queue<long long, vector<long long>, greater<long long> > q;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    long long t, w;
    cin >> t >> w;
    a[i] = make_pair(t, w);
  }
  sort(a + 2, a + n + 1);
  int ans = n, pos = n;
  for (;;) {
    for (; pos > 1 && a[pos].first > a[1].first; --pos)
      q.push(a[pos].second - a[pos].first + 1);
    ans = min(ans, (int)q.size() + 1);
    if (!q.empty() && a[1].first >= q.top()) {
      a[1].first -= q.top();
      q.pop();
    } else
      break;
  }
  cout << ans << '\n';
  return 0;
}
