#include <bits/stdc++.h>
using namespace std;
#define ll           long long
#define rep(i,j,n)   for(ll i=j;i<n;i++)
#define scn(a)       scanf("%lld",&a)
#define nl           printf("\n")
#define scns(a,b)    scanf("%lld %lld",&a,&b)
#define print(a)     printf("%lld",a)
#define tc           ll t; scn(t); while(t--)
#define vec          vector<ll>
#define pb           push_back
#define pairs        pair<ll,ll>
#define fi           first
#define se           second
#define all(v)       v.begin(),v.end()
#define srt(v)       sort(v.rbegin(),v.rend())
#define mem(a,b)     memset(a,b,sizeof(a))
#define maxx         5000005
#define inf          LLONG_MAX
#define zer          LLONG_MIN
#define dbug(a)      cout<<"dbug : "<<a<<endl
#define debug(a,b)   cout<<a<<" "<<b<<endl
#define read(v)      vec v(n,0); rep(i,0,n) {cin>>v[i];}
#define write(a,n)   rep(i,0,n) {cout<<a[i]<<" ";}
#define All          rep(i,0,n) 
const ll N = 4000;
const ll mod = 1000000000+7;	
ll zero = 0;

//1 - uska vote
//2 - mera vote



// bool comp(pair<ll,ll> p1, pair<ll,ll> p2) {
// 	if(p1.fi > p2.fi) return true;
// 	if(p1.fi == p2.fi) {
// 		if(v[p1.se].fi >= v[p2.se].fi) return true;
// 		else return false;
// 	}

// 	return false;
// }

void solve()
{
	
	ll n;
	cin >> n;

	vector<pair<ll,ll>> v(n);
	vector<pair<ll,ll>> total(n);

	ll totaluska = 0;
	
	rep(i,0,n) {
		cin >> v[i].fi;
		cin >> v[i].se;
		totaluska += v[i].fi;
	}

	
	rep(i,0,n) {
		ll tot = v[i].fi + v[i].se + v[i].fi;
		total[i] = {tot,i};
	}

	//sort(total.begin(), total.end()
	srt(total);

	ll mera = 0;
	ll uska = totaluska;
	ll i = 0;


	//cout << totaluska << endl;
	while(mera <= uska) {
		mera += total[i].fi - v[total[i].se].fi;
		uska -= v[total[i].se].fi;
		i++;

		
	}

	//cout << "mera " << mera << " uska " << uska << endl;


	cout << i;
	return;

	
}






//Check for test case
int main(){

 int test=1;

 //cin>>test;
 while(test--)
 {
 	solve();
 }
 return 0;
}

#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
    int n;
    cin>>n;
    pair<int,int> a[n];
    for(int i=0;i<n;i++){
        cin>>a[i].first>>a[i].second;
    }
    int x=0,y=0; // x-> aoki's votes and y-> takahashi's votes
    for(int i=0;i<n;i++){
        x+=a[i].first;
    }
    for(int i=0;i<n;i++){
        int temp = a[i].first;
        a[i].first = 2*a[i].first+a[i].second;
        a[i].second = temp;//{2a+b,a}
    }
    sort(a,a+n);
    int ans=0;
    int i=n-1;
    while(x>=y){
        ans++;
        y+=a[i].first-a[i].second;
        x-=a[i].second;
        i--;
    }
    cout<<ans;
    /*
        a[i].first=a,a[i].second=b;
        2*a+b
    */
}
