#include <bits/stdc++.h>
using namespace std;
struct Team {
  long long t;
  long long w;
  long long gap;
};
vector<long long> lowerque;
vector<Team> arr;
struct compare1 {
  bool operator()(const long long &a, const long long &b) const {
    return arr[a].w - arr[a].t > arr[b].w - arr[b].t;
  }
};
bool compare2(const long long &a, const long long &b) {
  return arr[a].t > arr[b].t;
};
priority_queue<long long, vector<long long>, compare1> upperque;
int main() {
  int n;
  scanf("%d", &n);
  arr.resize(n);
  for (int i = 0; i < n; i++) {
    scanf("%lld %lld", &arr[i].t, &arr[i].w);
    arr[i].gap = arr[i].w - arr[i].t + 1;
  }
  for (int i = 1; i < n; ++i) {
    if (arr[i].t > arr[0].t) {
      upperque.push(i);
    } else {
      lowerque.push_back(i);
    }
  }
  sort(lowerque.begin(), lowerque.end(), compare2);
  int indx = 0;
  long long pos = upperque.size();
  long long cur = pos;
  bool flag = true;
  auto &t = arr[0];
  while (!upperque.empty()) {
    auto &x = arr[upperque.top()];
    if (t.t >= x.w - x.t + 1) {
      t.t -= (x.w - x.t + 1);
      upperque.pop();
      while (indx < lowerque.size() && arr[lowerque[indx]].t > t.t) {
        upperque.push(lowerque[indx]);
        indx++;
      }
      cur = upperque.size();
      ((pos) = ((pos) < (cur) ? (pos) : (cur)));
    } else {
      break;
    }
  }
  cout << pos + 1 << endl;
  return 0;
}
