#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 10;
int n;
pair<pair<long long, long long>, int> arr[MAXN];
bool cmp(pair<pair<long long, long long>, int> a,
         pair<pair<long long, long long>, int> b) {
  if (a.first.first != b.first.first) return a.first.first > b.first.first;
  return (a.first.second - a.first.first + 1 <
          b.first.second - b.first.first + 1);
}
multiset<long long> ms;
void ispis() {
  for (auto it = ms.begin(); it != ms.end(); it++) cout << *it << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  long long x;
  for (int i = 0; i < n; i++) {
    cin >> arr[i].first.first >> arr[i].first.second;
    arr[i].second = i;
    if (i == 0) x = arr[i].first.first;
  }
  sort(arr, arr + n, cmp);
  int ind = 0, sol = MAXN;
  for (int i = 0; i < n; i++) {
    if (arr[i].first.first == x) {
      sol = i + 1;
      ind = i + 1;
      break;
    }
    ms.insert(arr[i].first.second - arr[i].first.first + 1);
  }
  if (sol == 1) {
    cout << 1 << endl;
    return 0;
  }
  while (true) {
    if ((int)ms.size() == 0) break;
    long long mini = *ms.begin();
    ms.erase(ms.begin());
    if (x < mini) break;
    x -= mini;
    int novi;
    for (int i = ind; i < n; i++) {
      novi = i;
      if (arr[i].first.first > x) {
        ms.insert(arr[i].first.second - arr[i].first.first + 1);
        novi++;
      } else
        break;
    }
    ind = novi;
    sol = min(sol, (int)ms.size() + 1);
  }
  cout << sol << endl;
  return 0;
}
