#include <bits/stdc++.h>
using namespace std;
template <typename T>
T input() {
  T ans = 0, m = 1;
  char c = ' ';
  while (!((c >= '0' && c <= '9') || c == '-')) c = getchar();
  if (c == '-') m = -1, c = getchar();
  while (c >= '0' && c <= '9') {
    ans = ans * 10 + (c - '0'), c = getchar();
  }
  return ans * m;
}
template <typename T>
void read(T& a) {
  a = input<T>();
}
template <typename T, typename... R>
void read(T& a, R&... r) {
  read(a);
  read(r...);
}
struct Team {
  int id;
  long long t, w;
};
struct cmp1 {
  bool operator()(const Team& a, const Team& b) {
    return make_pair(a.w - a.t, a.id) < make_pair(b.w - b.t, b.id);
  }
};
struct cmp2 {
  bool operator()(const Team& a, const Team& b) {
    return make_pair(a.t, a.id) > make_pair(b.t, b.id);
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  read(n);
  Team me;
  set<Team, cmp1> s;
  set<Team, cmp2> r;
  for (int i = 0; i < n; ++i) {
    long long t, w;
    read(t, w);
    if (!i) {
      me = {0, t, w};
    } else if (t > me.t) {
      s.insert({i, t, w});
    } else {
      r.insert({i, t, w});
    }
  }
  int ans = s.size();
  for (;;) {
    while (!r.empty() && r.begin()->t > me.t) {
      s.insert(*r.begin());
      r.erase(r.begin());
    }
    ans = min(ans, (int)s.size());
    if (s.empty()) break;
    me.t -= (s.begin()->w) - (s.begin()->t) + 1;
    if (me.t < 0) break;
    s.erase(s.begin());
  }
  cout << ans + 1 << "\n";
}
