#include <bits/stdc++.h>
using namespace std;
const double PI = acos(0) * 2;
const double EPS = 1e-8;
const long long MOD = 1e9 + 7;
const int MAXN = 3e5 + 5;
const int oo = 1e9;
const double foo = 1e30;
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return __builtin_popcounll(s);
}
template <class T>
T sqr(T x) {
  return x * x;
}
inline void addmod(int& a, int val, int p = MOD) {
  if ((a = (a + val)) >= p) a -= p;
}
inline void submod(int& a, int val, int p = MOD) {
  if ((a = (a - val)) < 0) a += p;
}
inline int mult(int a, int b, int p = MOD) { return (long long)a * b % p; }
int cmp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.first != b.first)
    return a.first > b.first;
  else
    return a.second < b.second;
}
int n;
long long t[MAXN], w[MAXN];
vector<pair<long long, long long> > v;
priority_queue<pair<long long, long long> > st, has;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%I64d%I64d", &t[i], &w[i]);
    if (i) v.push_back(make_pair(t[i], w[i]));
  }
  pair<long long, long long> a = make_pair(t[0], w[0]);
  v.push_back(make_pair(0, 0));
  sort(v.begin(), v.end(), cmp);
  int find = ((int)(v).size());
  if (v[0].first <= a.first) {
    cout << 1;
    return 0;
  }
  int ans = n - 1;
  long long ball = 0;
  for (int i = 0; i < ((int)(v).size()); i++) {
    if (v[i].first <= a.first) {
      if (i && v[i].first == v[i - 1].first) {
        long long rem = v[i].second - v[i].first + 1;
        if (!st.empty()) {
          long long cur = st.top().first;
          if (cur > rem) {
            ball = ball - cur + rem;
            pair<long long, long long> gg = st.top();
            st.pop();
            st.push(make_pair(rem, i));
            has.push(make_pair(-gg.first, gg.second));
          } else
            has.push(make_pair(-rem, i));
        } else
          has.push(make_pair(-rem, i));
      } else {
        long long chg = a.first - v[i].first;
        while (!has.empty() && ball - has.top().first <= chg) {
          pair<long long, long long> gg = has.top();
          st.push(make_pair(-gg.first, gg.second));
          has.pop();
          ball -= gg.first;
        }
        long long rem = v[i].second - v[i].first + 1;
        if (!st.empty()) {
          long long cur = st.top().first;
          if (cur > rem) {
            ball = ball - cur + rem;
            pair<long long, long long> gg = st.top();
            st.pop();
            st.push(make_pair(rem, i));
            has.push(make_pair(-gg.first, gg.second));
          } else
            has.push(make_pair(-rem, i));
        } else
          has.push(make_pair(-rem, i));
      }
      int pos = i - st.size();
      ans = min(ans, pos);
    } else {
      long long rem = v[i].second - v[i].first + 1;
      has.push(make_pair(-rem, i));
    }
  }
  cout << ans + 1;
}
