#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 2;
pair<long long, long long> p[N];
long long w[N];
long long t[N];
multiset<long long> s;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> t[i] >> w[i];
    p[i] = make_pair(t[i], w[i]);
  }
  sort(p + 2, p + n + 1, greater<pair<long long, long long> >());
  int res = n;
  for (int i = 2; 1;) {
    while (p[i].first > t[1]) {
      s.insert(p[i].second - p[i].first + 1);
      i++;
    }
    res = min(res, (int)s.size());
    if (!s.size() || t[1] < *(s.begin())) break;
    t[1] -= *(s.begin()), s.erase(s.begin());
  }
  cout << res + 1 << endl;
}
