#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFLL = 0x3f3f3f3f3f3f3f3fLL;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int maxn = 3e5 + 10;
int n;
struct node {
  long long num, w;
} a[maxn];
bool cmp1(node A, node B) { return A.num > B.num; }
bool operator<(const node &A, const node &B) {
  long long t1 = A.w - A.num + 1, t2 = B.w - B.num + 1;
  return t1 > t2;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].num >> a[i].w;
  }
  sort(a + 1, a + n, cmp1);
  long long x = a[0].num, ans = 0;
  priority_queue<node> q;
  int p = 0;
  for (int i = 1; i < n; i++) {
    if (a[i].num > x) {
      p = i;
      if (i == n - 1) p++;
      ans++;
      q.push(node{a[i].num, a[i].w});
    } else {
      p = i;
      break;
    }
  }
  ans++;
  long long tmp = ans;
  while (!q.empty()) {
    node now = q.top();
    q.pop();
    long long need = now.w - now.num + 1;
    if (x < need) break;
    x -= need;
    tmp--;
    for (int i = p; i < n; i++) {
      if (a[i].num > x) {
        p = i;
        if (i == n - 1) p++;
        tmp++;
        q.push(node{a[i].num, a[i].w});
      } else {
        p = i;
        break;
      }
    }
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
