#include <bits/stdc++.h>
using namespace std;
char c;
bool flag;
inline void read(int &a) {
  a = 0;
  do c = getchar();
  while (c != '-' && (c < '0' || c > '9'));
  c = c == '-' ? flag = true, getchar() : c;
  while (c <= '9' && c >= '0') a = (a << 3) + (a << 1) + c - '0', c = getchar();
  a = flag ? flag = false, -a : a;
}
inline void read(long long &a) {
  a = 0;
  do c = getchar();
  while (c != '-' && (c < '0' || c > '9'));
  c = c == '-' ? flag = true, getchar() : c;
  while (c <= '9' && c >= '0') a = (a << 3) + (a << 1) + c - '0', c = getchar();
  a = flag ? flag = false, -a : a;
}
inline int min(int a, int b) { return a > b ? b : a; }
inline int Min(int &a, int b) { return a > b ? a = b : a; }
inline int max(int a, int b) { return a < b ? b : a; }
inline int Max(int &a, int b) { return a < b ? a = b : a; }
int n;
pair<long long, long long> Team[1000001];
priority_queue<pair<long long, int> > Q;
int main() {
  read(n);
  for (int i = 1; i <= n; i++) read(Team[i].first), read(Team[i].second);
  sort(Team + 2, Team + 1 + n);
  long long ans = n, cnt = 0;
  int i = n;
  while (true) {
    if (!Q.empty())
      if (((Q.top().first) > 0 ? (Q.top().first) : -(Q.top().first)) <=
          Team[1].first)
        Team[1].first -=
            ((Q.top().first) > 0 ? (Q.top().first) : -(Q.top().first)),
            Q.pop(), cnt--;
    while (i > 1 && Team[1].first < Team[i].first) {
      Q.push(make_pair(-(Team[i].second - Team[i].first + 1), i));
      i--;
      cnt++;
    }
    ans = min(ans, cnt + 1);
    if (Q.empty() || ((Q.top().first) > 0 ? (Q.top().first)
                                          : -(Q.top().first)) > Team[1].first)
      break;
  }
  cout << ans << endl;
}
