#include <iostream>
#include <algorithm>
#include <set>
#include <numeric>
#include <iterator>
using namespace std;

typedef pair<int, int> P;
int N;
P A[300000];
multiset<int> os;

bool f(long long X) {
  multiset<int> s(os);
  multiset<int> g;
  long long t = 0;
  for (int i=0; i<X-1; i++) {
    int x = A[i].second;
    s.erase(s.find(x));
    g.insert(x);
    t += x;
  }

  for (int i=0; i<N-X+1; i++) {
    int x = A[i].second;
    long long b = (long long)A[i].first * X - x;
    auto it = g.find(x);
    if (it != g.end()) {
      g.erase(g.find(x));
      long long d = *s.begin();
      s.erase(s.begin());
      g.insert(d);
      t += d - x;
    }
    else s.erase(s.find(x));
    if (t <= b) return true;
  }
  return false;
}

int main() {
  cin >> N;
  for (int i=0; i<N; i++) {
    int a, b;
    cin >> a >> b;
    A[i] = P(b, a);
  }
  sort(A, A+N);
  for (int i=0; i<N; i++) os.insert(A[i].second);

  int lo = 0, hi = N+1;
  while (hi - lo > 1) {
    int mid = (lo + hi) / 2;
    if (f(mid)) lo = mid;
    else        hi = mid;
  }
  cout << lo << "\n";
  return 0;
}