#include <bits/stdc++.h>
using namespace std;
const string NAME = "";
const int N = 3e5 + 7;
int n, res;
pair<long long, long long> team[N];
struct cmp {
  bool operator()(pair<long long, long long> A, pair<long long, long long> B) {
    return A.second - A.first > B.second - B.first;
  };
};
bool cmp2(pair<long long, long long> A, pair<long long, long long> B) {
  return A.first > B.first;
}
void Enter() {
  cin >> n;
  for (int i = (1), _b = (n); i <= _b; ++i)
    cin >> team[i].first >> team[i].second;
  sort(team + 2, team + 1 + n, cmp2);
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >, cmp>
      heap;
  int i = 2;
  long long cur = team[1].first;
  res = 1;
  for (int j = (2), _b = (n); j <= _b; ++j)
    if (team[j].first > cur) res = j, i = j + 1, heap.push(team[j]);
  while (heap.size() && cur >= heap.top().second - heap.top().first) {
    pair<long long, long long> u = heap.top();
    heap.pop();
    cur -= u.second - u.first + 1;
    while (i <= n && team[i].first > cur) heap.push(team[i]), ++i;
    int sx = heap.size();
    res = min(res, sx + 1);
  }
  cout << res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  Enter();
}
