#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define ll long long

int main(){
	int T;
	int n;
	cin>>n;
	vector<ll> a(n);
	ll ta=0,tb=0;
	for(int i=0;i<n;i++){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		ta+=x;
		a[i]=x+y+x;
	}
	sort(a.begin(), a.end(),greater<ll>() );
	int res=0;
	while(tb<=ta){
		tb+=a[res];
		res++;
	}
	//cout<<ta<<" "<<tb<<endl;
	printf("%d\n",res);
		
		
	return 0;
}

// Problem: D - Choose Me
// Contest: AtCoder - AtCoder Beginner Contest 187
// URL: https://atcoder.jp/contests/abc187/tasks/abc187_d
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;
using db = double;
using str = string;

using pi = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<db,db>;

using vi = vector<int>;
using vl = vector<ll>;

#define mp make_pair
#define f first
#define s second

#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back

void divisors(map<int,int>& d,ll N){
	for(int div : {2,3,5}){
		int cnt=1;
		if(N%2==0){
			while((N%2)==0){
				N/=2;
				cnt++;
			}
			d[div]=cnt;
		}
	}
	static array<int,8> increments = {4,2,4,2,4,6,2,6};
	int i=0;
	for(ll div=7;div*div<=N;div+=increments[i++]){
		if((N%div)==0){
			int cnt=1;
			while((N%i)==0){
				N/=i;
				cnt++;
			}
			d[i]=cnt;
		}
		if(i==8)
			i=0;
	}
	if(N>1)
		d[N]=2;
}

ll solve(int T){
	vl town(T);
	ll baseline=0;
	for(int i=0;i<T;i++){
		ll a,b;
		cin>>a>>b;
		town[i]=2ll*a+b;
		baseline-=a;
	}
	sort(town.begin(),town.end());
	while(baseline<=0 && !town.empty()){
		baseline+=town.back();
		town.pop_back();
	}
	return T-(int)town.size();
}

int main(){
	int T;
	cin>>T;
	cout<<solve(T)<<"\n";
	
	
	return 0;	
}
