#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
typedef long long LL;
typedef pair<LL, LL> PII;

PII vote[N];
LL n;

bool cmp(PII, PII);

int main(){
    cin >> n;
    LL va = 0, vb = 0;
    for(LL i = 1; i <= n; i++){
        cin >> vote[i].first >> vote[i].second;
        va += vote[i].first;
    }
    sort(vote + 1, vote + 1 + n, cmp);
    for(LL i = 1; i <= n; i++){
        va -= vote[i].first;
        vb += (vote[i].second + vote[i].first);
        if(vb > va){
            printf("%lld\n", i);
            return 0;
        }
    }
    return 0;
}

bool cmp(PII a, PII b){
    if((a.first * 2 + a.second) != (b.first * 2 + b.second))
        return (a.first * 2 + a.second) > (b.first * 2 + b.second);
    else return a.first > b.first;
}
#include<bits/stdc++.h>
using namespace std;
#define setbits(x)      __builtin_popcountll(x)
#define leadzero(x)     __builtin_clz(x)
#define trailzero(x)    __builtin_ctz(x)
#define mod             1000000007
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll              long long 
#define int             ll
#define ld              long double
#define ff              first
#define ss              second
#define pb              push_back
#define eb              emplace_back
#define popb            pop_back
#define endl            '\n'
#define all(v)          v.begin(), v.end()
#define sz(x)           ((int)((x).size()))
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<int, pii> pip;
typedef pair<pii, int> ppi;
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii;
typedef vector<pll> vll; 
typedef vector<ll> vl; 
typedef vector<vl> vvl;
typedef vector<string> vs;
ll power(ll a, ll b) {
    if(b<0) return 1;
    ll res=1;
    while(b) {
        if(b&1) 
            res = (res*a);//%mod;
        a = (a*a);//%mod;
        b >>= 1;
    }
    return res;
}
template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
bool ispoweroftwo(ll x){ return (x&&!(x&(x-1)));}
ll GCD(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
ll LCM(ll a, ll b) {return a / GCD(a, b) * b;}
const int inf = 1e9;
const ll INF = 1e18;
const ld pi = 3.141592653589793238;
int dx[] = {-1, 0, 1, 0}; 
int dy[] = {0, 1, 0, -1};
char MV[] = {'U', 'R', 'D', 'L'};
//Shoot for the moon - If you miss, you'll end up in the stars
//integer to char always remember (char+'0')
//---------------------------------------------------------------------------------------
int32_t main() {
    FIO;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int n;
    cin >> n;
    vi a(n), b(n);
    vector<pll> v;
    ll aoki = 0, taka = 0;
    rep(i, n) {
    	cin >> a[i] >> b[i];
    	v.pb({2 * a[i] + b[i], i});
    	aoki += a[i];
    }

    sort(all(v));

    ll ans = 0;
    for (int i = n-1; i >= 0 && aoki >= taka; --i) {
    	ans++;
    	int ind = v[i].ss;
    	aoki -= a[ind];
    	taka += a[ind] + b[ind];
    }
    cout << ans;
    return 0;
}
