#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
int n;
pair<long long, long long> a[maxn + 1];
pair<long long, long long> b;
priority_queue<long long, vector<long long>, greater<long long> > q;
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  return a > b;
}
int main() {
  int ans;
  scanf("%d\n", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld%lld", &a[i - 1].first, &a[i - 1].second);
  }
  b = a[0];
  sort(a + 1, a + n, cmp);
  int i = 1;
  for (; i <= n && a[i].first > b.first; i++)
    q.push(a[i].second - a[i].first + 1);
  ans = i;
  int lans = 0;
  while (!q.empty()) {
    long long k = q.top();
    q.pop();
    if (k > b.first) break;
    b.first -= k;
    lans++;
    for (; i <= n && a[i].first > b.first; i++)
      q.push(a[i].second - a[i].first + 1);
    ans = min(ans, i - lans);
  }
  printf("%d\n", ans);
  return 0;
}
