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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)
#define DEB(x)	cout << #x << " " << x << endl;
#define DEB_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

typedef long long int LL;
typedef pair<int, int> PI;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VL;

struct bySum{
	bool operator() (PI a, PI b) {
		return 2*(LL)a.first+a.second > 2*(LL)b.first+b.second;
	}
};

int main() {

	IOS

	int n;
	cin >> n;
	int a[n], t[n];
	REP(i, n)
		cin >> a[i] >> t[i];

	LL suma = 0;
	REP(i, n)
		suma += a[i];

	PI at[n];
	REP(i, n)
		at[i] = {a[i], t[i]};

	sort(at, at+n, bySum());

	// DEB(suma);
	// REP(i, n)
	// 	cout << at[i] << "," << at[i].second << " ";
	// cout << endl;

	int c = 0, ai = 0;
	LL sumt = 0;

	while (suma >= sumt) {
		sumt += (LL)at[ai].first + at[ai].second;
		suma -= at[ai].first;

		ai++;
		// DEB(suma);
		// DEB(sumt);
		c++;
	}

	cout << c;

	return 0;
}
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
bool cmp(pair<ll,ll> a, pair<ll, ll> b){
    return (2*a.first+a.second) > (2*b.first+b.second);
}



int main(){
    ll n, i, ans=0, ak=0, x, y;
    cin>>n;
    vector<pair<ll, ll>> vt;
    for(i=0;i<n;i++){
        cin>>x>>y;
        vt.push_back({x, y});
        ak+=x;
    }
    sort(vt.begin(), vt.end(), cmp);
    for(i=0;i<n;i++){
        ans+=vt[i].first+vt[i].second;
        ak-=vt[i].first;
        if(ans>ak){
            cout<<i+1;
            return 0;
        }
    }
}

