#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <random>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int lli;
typedef pair<int,int> pii;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

inline bool CompareByB(const pii x,const pii &y){
	return x.second>y.second;
}

class SegmentTree{
	private:
	int size;
	public:
	vector<int> data1;
	vector<int> data2;
	void Init(int n){
		size=1;
		while(size<n) size*=2;
		data1=vector<int>(size*2,0);
		data2=vector<int>(size*2,0);
	}
	void Update(int k,int val){
		k+=size-1;
		data1[k]=val;
		data2[k]=k-size+1;
		while(k>0){
			k=(k-1)/2;
			if(data1[2*k+1]>data1[2*k+2]){
				data1[k]=data1[k*2+1];
				data2[k]=data2[k*2+1];
			}else{
				data1[k]=data1[k*2+2];
				data2[k]=data2[k*2+2];
			}
		}
	}
	int GetMaxVal(){
		return data1[0];
	}
	int GetMaxId(){
		return data2[0];
	}
};

int N;

bool Check(int x,vector<pii> &seq){
	SegmentTree tree;
	tree.Init(x);
	lli sum=0;
	REP(i,0,x-1){
		sum+=seq[i].first;
		tree.Update(i,seq[i].first);
	}
	REP(i,x-1,N){
		if(i==x-1){
			sum+=seq[i].first;
			tree.Update(i,seq[i].first);
		}else{
			if(tree.GetMaxVal()>seq[i].first){
				sum-=tree.GetMaxVal()-seq[i].first;
				tree.Update(tree.GetMaxId(),seq[i].first);
			}
		}
		if(sum<=(lli)seq[i].second*x) return true;
	}
	return false;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> N;
	vector<pii> seq(N);
	REP(i,0,N){
		int a,b;
		cin >> a >> b;
		seq[i]=MP(a,b); //放出量A,許容量B
	}
	sort(seq.begin(),seq.end(),CompareByB);
	int lb=0,ub=N;
	while(true){
		if(ub-lb==1){
			if(Check(ub,seq)) lb=ub;
			break;
		}
		int mid=(lb+ub)/2;
		if(Check(mid,seq)) lb=mid;
		else ub=mid;
	}
	cout << lb << endl;
	return 0;
}