#include <bits/stdc++.h>
using namespace std;
const long long INF = LLONG_MAX / 2;
struct team {
  long long b, w;
  int id, ordB;
};
long long add(long long a, long long b) {
  if (a > INF - b) {
    return INF;
  }
  return a + b;
}
long long bitSum[300005];
int bitCnt[300005];
void update(int pos, long long sum, int cnt) {
  for (int i = pos + 1; i < 300005; i += i & -i) {
    bitSum[i] = add(bitSum[i], sum);
    bitCnt[i] += cnt;
  }
}
pair<long long, int> query(int pos) {
  pair<long long, int> ret;
  for (int i = pos + 1; i > 0; i -= i & -i) {
    ret.first = add(ret.first, bitSum[i]);
    ret.second += bitCnt[i];
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<team> a(n + 1);
  map<long long, int> bs;
  for (int i = 0; i < n; i++) {
    cin >> a[i].b >> a[i].w;
    a[i].id = i;
    long long x = a[i].w - a[i].b + 1;
    if (bs.count(x) == 0) {
      bs[x] = 0;
    }
    bs[x]++;
  }
  {
    a[n].b = 0;
    a[n].w = 0;
    a[n].id = n;
    long long x = a[n].w - a[n].b + 1;
    if (bs.count(x) == 0) {
      bs[x] = 0;
    }
    bs[x]++;
    n++;
  }
  int tot = 0;
  for (auto &it : bs) {
    it.second += tot;
    tot = it.second;
  }
  assert(tot == n);
  for (int i = 0; i < n; i++) {
    long long x = a[i].w - a[i].b + 1;
    a[i].ordB = --bs[x];
  }
  long long b = a[0].b;
  sort((a).begin(), (a).end(), [](const team &a, const team &b) {
    if (a.b != b.b) {
      return a.b > b.b;
    } else {
      return a.id < b.id;
    }
  });
  int initialRank = 1;
  for (int i = 0; i < n; i++) {
    if (a[i].b > b) {
      initialRank++;
    }
  }
  int ans = initialRank;
  int curRank = 1;
  int i = 0;
  while (i < n) {
    if (a[i].b <= b) {
      long long can = b - a[i].b;
      int lo = -1, hi = n;
      while (lo + 1 < hi) {
        int mid = (lo + hi) / 2;
        auto it = query(mid);
        if (it.first <= can) {
          lo = mid;
        } else {
          hi = mid;
        }
      }
      auto it = query(lo);
      ans = min(ans, curRank - it.second);
    }
    int j = i;
    while (j < n && a[j].b == a[i].b) {
      if (a[j].id != 0) {
        update(a[j].ordB, a[j].w - a[j].b + 1, 1);
      }
      j++;
      if (j > i + 1 || a[i].id != 0) {
        curRank++;
      }
    }
    i = j;
  }
  cout << ans << endl;
  return 0;
}
