#include <bits/stdc++.h>
const int N = 3e5 + 10;
const int MOD = 1e9 + 7;
const int INF = 2e9;
using namespace std;
pair<long long, long long> a[N];
int n;
long long x, y;
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  cin >> x >> y;
  n--;
  for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
  sort(a, a + n);
  reverse(a, a + n);
  priority_queue<long long, vector<long long>, greater<long long> > p;
  int pos = 0;
  int res = 1;
  int ans = INF;
  while (1) {
    int lo = pos, hi = n - 1, key = -1;
    while (lo <= hi) {
      int mid = (lo + hi) / 2;
      if (a[mid].first > x) {
        key = mid;
        lo = mid + 1;
      } else
        hi = mid - 1;
    }
    if (key != -1) {
      for (int i = pos; i <= key; i++) p.push(a[i].second - a[i].first + 1);
      res += key - pos + 1;
      ans = min(ans, res);
      pos = key + 1;
    } else
      ans = min(ans, res);
    ;
    if (p.empty()) break;
    long long w = p.top();
    p.pop();
    if (x < w) break;
    res--;
    x -= w;
  }
  cout << ans;
  return 0;
}
