#include <bits/stdc++.h>
using namespace std;
const int M = 300300;
int n;
long long T;
pair<long long, long long> a[M];
int ptr = 0;
int cur = 0;
priority_queue<long long, vector<long long>, greater<long long>> q;
void read() {
  cin >> n;
  long long w;
  cin >> T >> w;
  --n;
  for (int i = 0; i < n; ++i) {
    long long t, w;
    cin >> t >> w;
    a[i] = make_pair(t, w);
  }
}
long long diff(int ptr) { return a[ptr].second - a[ptr].first + 1; }
void go() {
  while (ptr < n && a[ptr].first > T) {
    q.push(diff(ptr));
    ++ptr;
    ++cur;
  }
}
void kill() {
  sort(a, a + n);
  reverse(a, a + n);
  int ans = 0;
  go();
  ans = cur;
  while (!q.empty() && T > 0) {
    long long mn = q.top();
    q.pop();
    if (mn > T) break;
    T -= mn;
    --cur;
    go();
    ans = min(ans, cur);
  }
  cout << ans + 1 << endl;
}
int main() {
  cout.precision(20);
  cout << fixed;
  ios_base::sync_with_stdio(false);
  read();
  kill();
}
