#include <bits/stdc++.h>
using namespace std;
int n, p = 2e9, f, m, l, id, idc;
pair<long long, long long> my, t[300005], c;
priority_queue<long long> mq;
int main() {
  scanf("%d%I64d%I64d", &n, &my.first, &my.second);
  for (int i = 0; i < n - 1; i++)
    scanf("%I64d%I64d", &t[i].first, &t[i].second);
  sort(t, t + n - 1);
  f = l = 1;
  for (int i = n - 2; i >= 0; i--) {
    if (t[i].first > my.first)
      l++;
    else
      break;
  }
  while (f <= l) {
    while (!mq.empty()) mq.pop();
    m = (f + l) / 2;
    c = my;
    for (idc = n - 2; idc >= 0; idc--) {
      if (t[idc].first > c.first)
        mq.push(t[idc].first - t[idc].second - 1);
      else
        break;
    }
    while (mq.size() != m - 1 && c.first >= 0) {
      c.first += mq.top();
      mq.pop();
      for (; idc >= 0; idc--) {
        if (t[idc].first > c.first)
          mq.push(t[idc].first - t[idc].second - 1);
        else
          break;
      }
    }
    if (mq.size() == m - 1 && c.first >= 0) {
      p = min(p, m);
      l = m - 1;
    } else
      f = m + 1;
  }
  printf("%d", p);
  return 0;
}
