#include <bits/stdc++.h>
using namespace std;
const long long INF = 1ll * 1e18;
pair<long long, int> t[1200200];
pair<long long, long long> a[300300];
pair<long long, int> fmin(int l, int r, int lv, int rv, int v) {
  if (lv > r || rv < l) return make_pair(INF, -1);
  if (lv >= l && rv <= r) return t[v];
  return min(fmin(l, r, lv, (lv + rv) / 2, v * 2),
             fmin(l, r, (lv + rv) / 2 + 1, rv, v * 2 + 1));
}
void modify(int v) {
  t[v] = make_pair(INF, -1);
  v /= 2;
  while (v > 0) {
    t[v] = min(t[v * 2], t[v * 2 + 1]);
    v /= 2;
  }
}
int main() {
  int n;
  cin >> n;
  n--;
  int z = 1;
  while (z < n) z *= 2;
  long long K, W;
  cin >> K >> W;
  for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
  sort(a, a + n, greater<pair<long long, int> >());
  for (int i = 0; i < n; i++)
    t[z + i] = make_pair(a[i].second - a[i].first + 1, i);
  for (int i = n; i < z; i++) t[i + z] = make_pair(INF, -1);
  for (int i = z - 1; i > 0; i--) t[i] = min(t[i * 2], t[i * 2 + 1]);
  int j = 0;
  while (j < n && a[j].first > K) j++;
  int kl = 0;
  if (j == 0) {
    cout << 1 << endl;
    return 0;
  }
  int ans = j + 1;
  while (K > 0) {
    pair<long long, int> x = fmin(1, j, 1, z, 1);
    if (x.second == -1) break;
    if (K < x.first) break;
    K -= x.first;
    modify(x.second + z);
    kl++;
    while (j < n && a[j].first > K) j++;
    ans = min(ans, j + 1 - kl);
  }
  cout << ans << endl;
}
