#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

int N, n;
pair<int, int>p[300000];
bool ok(int t) {
	priority_queue<int>Q; ll sum = 0;
	for (int i = n - 1; i >= n - t + 1; i--) {
		Q.push(p[i].second); sum += p[i].second;
	}
	if (p[n - t].first*(ll)t >= sum + p[n - t].second)return 1;
	for (int i = n - t; i > 0; i--) {
		if (!Q.empty() && Q.top() > p[i].second) {
			sum -= Q.top() - p[i].second; Q.pop();
			Q.push(p[i].second);
		}
		if (p[i - 1].first*(ll)t >= sum + p[i - 1].second)return 1;
	}
	return 0;
}
int main() {
	scanf("%d", &n);
	rep(i, n) {
		int a, b; scanf("%d%d", &a, &b);
		p[i] = { b,a };
	}
	sort(p, p + n);
	int a = 0, b = n;
	while (a != b) {
		int t = (a + b) / 2;
		if (b - a == 1)t = b;
		if (ok(t))a = t;
		else b = t - 1;
	}
	printf("%d\n", a);
}