#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
struct edge {
  int u, v, w, index;
  edge();
  edge(int a, int b, int c, int d) : u(a), v(b), w(c), index(d) {}
};
priority_queue<long long, vector<long long>, greater<long long>> qq;
deque<pair<long long, long long>> deq;
int main() {
  int n;
  cin >> n;
  long long t, w, t1, w1;
  cin >> t1 >> w1;
  for (int i = 1; i < n; i++) {
    cin >> t >> w;
    if (t > t1) {
      qq.push(w - t);
    } else {
      deq.push_back({t, w - t});
    }
  }
  sort(deq.begin(), deq.end(), greater<pair<long long, long long>>());
  long long ans = qq.size() + 1;
  while (!qq.empty()) {
    long long needed = qq.top() + 1;
    if (t1 >= needed) {
      qq.pop();
      t1 -= needed;
      while (!deq.empty() && t1 < deq.begin()->first) {
        qq.push(deq.begin()->second);
        deq.pop_front();
      }
      ans = min(ans, (long long)qq.size() + 1);
    } else {
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
