#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const long long INF = 1e9 + 19;
int n;
pair<long long, long long> b[N];
long long T;
void read() {
  scanf("%d", &n);
  long long w;
  scanf("%lld%lld", &T, &w);
  n--;
  for (int i = 0; i < n; i++) {
    scanf("%lld%lld", &b[i].first, &b[i].second);
  }
}
void solve() {
  sort(b, b + n, greater<pair<long long, long long>>());
  multiset<long long> q;
  int answer = INF;
  int rem = 0;
  int cur = 0;
  for (;;) {
    for (; cur < n && b[cur].first > T; cur++) {
      q.insert(b[cur].second - b[cur].first + 1);
    }
    answer = min(answer, cur - rem);
    if (q.empty()) break;
    long long x = *q.begin();
    if (T >= x) {
      T -= x;
      rem++;
      q.erase(q.begin());
    } else
      break;
  }
  cout << answer + 1 << endl;
}
void stress() {}
int main() {
  if (1) {
    int k = 1;
    for (int tt = 0; tt < k; tt++) {
      read();
      solve();
    }
  } else {
    stress();
  }
  return 0;
}
