#include<bits/stdc++.h>
using namespace std;
struct node{long long x,y;}f[200002];
long long n,a=0,b=0,cnt=0;
bool cmp(node x,node y){return 2*x.x+x.y>2*y.x+y.y;}
int main(){
    scanf("%lld",&n);
    for(int i=0;i<n;++i)scanf("%lld%lld",&f[i].x,&f[i].y),a+=f[i].x;
    sort(f,f+n,cmp);
    while(b<=a){b+=f[cnt].x+f[cnt].y;a-=f[cnt].x;++cnt;}
    printf("%lld",cnt);
    return 0;
}
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define REP(i,n) for(int i=0;i<(n);++i)
#define COUT(x) cout<<(x)<<"\n"
#define COUT16(x) cout << fixed << setprecision(16) << (x) << "\n";

int main(){
    int n;cin >> n;
    ll a[n],b[n];
    ll sum_a = 0;
    vector<ll> sum_ad;
    REP(i,n){
        cin >> a[i] >> b[i];
        sum_a += a[i];
        sum_ad.push_back(2*a[i]+b[i]);
    }
    sort(sum_ad.begin(),sum_ad.end(),greater<ll>());
    ll count = 0,sum=0;
    REP(i,n){
        sum += sum_ad[i];
        count++;
        if(sum>sum_a){
            COUT(count);
            return 0;
        }
    }
}