#include <bits/stdc++.h>
using namespace std;
const int N = 4e5;
multiset<long long> s;
struct node {
  long long x, y;
} a[N];
bool cmp(node a, node b) { return a.x > b.x; }
int main() {
  int n;
  long long x, y;
  scanf("%d", &n);
  scanf("%I64d%I64d", &x, &y);
  for (int i = 0; i < n - 1; i++) {
    scanf("%I64d%I64d", &a[i].x, &a[i].y);
  }
  sort(a, a + n - 1, cmp);
  int l = 0;
  int ans = n + 1;
  while (1) {
    while (a[l].x > x && l < n - 1) {
      s.insert(a[l].y - a[l].x + 1);
      l++;
    }
    ans = min(ans, (int)s.size());
    if (s.empty()) break;
    multiset<long long>::iterator it = s.begin();
    long long t = *it;
    if (t > x)
      break;
    else {
      x -= t;
      s.erase(it);
    }
  }
  if (ans == n + 1) ans = 0;
  printf("%d\n", ans + 1);
  return 0;
}
