#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for (ll i = 1; i < (ll)(n + 1); i++)
int digsum(ll N){
    bool a=true;
    ll ans=0;
    while(a==true){
        if(0<N){
            ans+=N++;
            N-=N%10;
            N/=10;
        }
        else{
            a=false;
        }
    }
    return ans;
}
int main() {
    int N;
    cin>>N;
    vector<ll>A(N);
    vector<ll>B(N);
    vector<ll>cn(N);
    ll cnt=0;
    ll ans=0;
    ll an=0;
    rep(i,N){
        cin>>A[i];
        cin>>B[i];
        cn[i]=A[i]*2+B[i];
        cnt+=A[i];
    }
    sort(cn.rbegin(),cn.rend());
    rep(i,N){
        ans+=cn[i];
        if(cnt<ans){
            cout<<i+1<<endl;
            i+=N;
        }
    }
}

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
 
bool cmp(pair<ll,ll>a,pair<ll,ll>b){
    ll suma = 2*a.first+a.second;
	ll sumb = 2*b.first+b.second;
	return suma > sumb;
}
 
int main(){
    ll n,k;
    cin>>n;
    vector<pair<ll,ll>>vp;
	ll d=0,t=0,cnt;
    for(int i=0;i<n;i++)
    {
        ll a,b;
        cin>>a>>b;
    	d+=a;
        vp.push_back({a,b});
    }
    
	sort(vp.begin(),vp.end(),cmp);
 
	t=0,cnt=1;
	for(auto it:vp)
	{
		t+=it.first+it.second;
		d-=it.first;
		if(t<=d)
		    cnt++;
		else break;
	}
 
	cout<<cnt<<endl;
    return 0;
}