#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;

struct Bug{
	int out,in;
	bool operator <(const Bug &a)const{
		return in>a.in;
	}
};

int N;
Bug b[300000];

bool isTokyo(int k){
	multiset<int> latte;
	ll sum = 0;
	for(int i=0;i<N;i++){
		if(latte.size()<k-1){
			sum += b[i].out; latte.insert(b[i].out); continue;
		}
		if((double)(sum+b[i].out)/(double)k<=(double)b[i].in) return true;
		if(latte.size()==0) continue;
		multiset<int>::iterator max_ = latte.end(); max_--;
		if(*max_>b[i].out){
			sum -= *max_;
			latte.erase(max_);
			sum += b[i].out;
			latte.insert(b[i].out);
		}
	}
	return false;
}

signed main(){
	cin>>N;
	for(int i=0;i<N;i++) cin>>b[i].out>>b[i].in;
	sort(b,b+N);
	int l=0, r=N+1;
	while(l+1 != r){
		int piv = (l+r)/2;
		if(isTokyo(piv)) l = piv;
		else r = piv;
	}
	printf("%d\n",l);
	return 0;
}