#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

template<int size>
struct BIT
{
	// [0,size]
	LL tree[size+1];
	void add(int i,LL v){
		i++;
		while(i<=size){
			tree[i]+=v;
			i+=(i&-i);
		}
	}

	// [0,i]
	LL collect(int i){
		i++;
		LL r=0;
		while(i>0){
			r+=tree[i];
			i-=(i&-i);
		}
		return r;
	}

	// [a,b]
	LL collect(int a, int b){
		return collect(b)-collect(a-1);
	}
};

BIT<100*1000+1> sum, num;
vector<int> as[100*1000+1];
int N;
int main() {
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		as[b].push_back(a);
	}
	LL r=0;
	for(int b=100*1000;b>0;b--){
		if(as[b].size()==0)continue;
		for(auto a:as[b]){
			sum.add(a,a);
			num.add(a,1);
		}
		int low=b;
		int hi=100*1000+1;
		while(low+1<hi){
			int mid=(low+hi)/2;
			LL k=num.collect(mid);
			LL s=sum.collect(mid);
			if(s<=k*b){
				low=mid;
			}
			else{
				hi=mid;
			}
		}
		{
			LL k=num.collect(low);
			LL kk=num.collect(low+1);
			LL s=sum.collect(low);
			r=max(r,k+min(kk-k,(k*b-s)/(low+1-b)));
		}
	}
	printf("%lld\n",r);

}