#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1.0);
const long long LINF = (long long)1e18 + 5;
const int INF = (int)1e9 + 5;
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T abs(T x) {
  return x < 0 ? -x : x;
}
template <class T>
long long round(T x) {
  return x < 0 ? x - 0.5 : x + 0.5;
}
template <class T>
bool chmin(T& x, const T& y) {
  if (y < x) {
    x = y;
    return true;
  }
  return false;
}
template <class T>
bool chmax(T& x, const T& y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}
template <class P, class Q>
ostream& operator<<(ostream& os, const pair<P, Q>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  bool was = false;
  os << "{";
  for (typename vector<T>::const_iterator it = v.begin(); it != v.end(); it++) {
    if (was) {
      os << ", ";
    } else {
      was = true;
    }
    os << *it;
  }
  os << "}";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const set<T>& v) {
  bool was = false;
  os << "{";
  for (typename set<T>::const_iterator it = v.begin(); it != v.end(); it++) {
    if (was) {
      os << ", ";
    } else {
      was = true;
    }
    os << *it;
  }
  os << "}";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const multiset<T>& v) {
  bool was = false;
  os << "{";
  for (typename multiset<T>::const_iterator it = v.begin(); it != v.end();
       it++) {
    if (was) {
      os << ", ";
    } else {
      was = true;
    }
    os << *it;
  }
  os << "}";
  return os;
}
template <class P, class Q>
ostream& operator<<(ostream& os, const map<P, Q>& v) {
  bool was = false;
  os << "{";
  for (typename map<P, Q>::const_iterator it = v.begin(); it != v.end(); it++) {
    if (was) {
      os << ", ";
    } else {
      was = true;
    }
    os << *it;
  }
  os << "}";
  return os;
}
template <class T>
T nextInt() {
  long long x = 0;
  bool p = false;
  char c;
  do {
    c = getchar();
  } while (c <= 32);
  if (c == '-') {
    p = true;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return (p ? -x : x);
}
string nextToken() {
  static char str[200200];
  scanf("%s", str);
  return str;
}
const int N = 300300;
int n;
long long t[N], w[N];
struct cmpByDiff {
  bool operator()(int i, int j) {
    return make_pair(w[i] - t[i], i) < make_pair(w[j] - t[j], j);
  }
};
struct cmpByT {
  bool operator()(int i, int j) {
    return make_pair(t[i], i) > make_pair(t[j], j);
  }
};
set<int, cmpByDiff> topSet;
set<int, cmpByT> loserSet;
void answer(int x) {
  printf("%d\n", x);
  exit(0);
}
void solve() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld%lld", t + i, w + i);
  }
  long long curT = t[0];
  for (int i = 1; i < n; i++) {
    if (t[i] > curT) {
      topSet.insert(i);
    } else {
      loserSet.insert(i);
    }
  }
  int best = (int)topSet.size() + 1;
  while (true) {
    best = min(best, (int)topSet.size() + 1);
    if (topSet.empty()) {
      answer(1);
    }
    int idx = *topSet.begin();
    topSet.erase(idx);
    long long cost = w[idx] - t[idx] + 1;
    if (cost > curT) break;
    curT -= cost;
    while (!loserSet.empty()) {
      int jdx = *loserSet.begin();
      loserSet.erase(jdx);
      if (t[jdx] > curT) {
        topSet.insert(jdx);
      } else {
        loserSet.insert(jdx);
        break;
      }
    }
  }
  answer(best);
}
int main() {
  srand(time(0));
  int t = 1;
  while (t--) solve();
}
