#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
struct bug{ll in,out;};
int N,size;
int seg1[1<<20],seg2[1<<20];
bug foo[300050];
bool comp(const bug& a,const bug& b)
{
	return a.in > b.in;
}
struct segtree
{
	segtree(int n)//constructor making segtree
	{
		size=1;
		memset(seg1,0,sizeof(seg1));
		memset(seg2,0,sizeof(seg2));
		while(size<n)size*=2;
	}
	void update(int k,int x)
	{
		k+=size;
		seg1[k]=x;
		seg2[k]=k-size;
		while(k>0)
		{
			k=(k-1)/2;
			if(seg1[k*2+1]>seg1[k*2+2])
			{
				seg1[k]=seg1[k*2+1];
				seg2[k]=seg2[k*2+1];
			}
			else
			{
				seg1[k]=seg1[k*2+2];
				seg2[k]=seg2[k*2+2];
			}
		}
		return;
	}
	int max_id()
	{
		return seg2[0];
	}
	int max_num()
	{
		return seg1[0];
	}
};
bool C(int K)
{
	segtree seg(K);
	ll sum=0ll;
	for(int i=0;i<K-1;i++)
	{
		sum+=(ll)foo[i].out;
		seg.update(i,foo[i].out);
	}
	for(int i=K-1;i<N;i++)
	{
		if(i==K-1)
		{
			sum+=(ll)foo[i].out;
			seg.update(i,foo[i].out);
		}
		else
		{
			if(seg.max_num()>foo[i].out)
			{
				sum-=(ll)(seg.max_num()-foo[i].out);
				seg.update(seg.max_id(),foo[i].out);
			}
		}
		if(sum<=(ll)K*foo[i].in)return true;
	}
	return false;
}
int main()
{
	cin >> N;
	for(int i=0;i<N;i++)cin >> foo[i].out >> foo[i].in;
	sort(foo,foo+N,comp);
	int l=0,r=N;
	while(r>l)
	{
		if(r-l==1)
		{
			if(C(r))l=r;
			break;
		}
		int mid=(l+r)/2;
		if(C(mid))l=mid;
		else r=mid;
	}
	cout << l << endl;
	return 0;
}