#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
int main(){
    int i,n; cin >> n;
    ll s = 0;
    vector<ll> v;
    for(i=0;i<n;i++){
        ll a,b; cin >> a >> b;
        s -= a;
        v.push_back(2*a + b);
    }
    sort(v.rbegin(),v.rend());
    for(i=0;i<n;i++){
        s += v[i];
        if(s>0){
            cout << i + 1 << endl;
            return 0;
        }
    }
}
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N),B(N),get(N);
    ll a = 0,b = 0;
    rep(i,N){
        cin >> A[i] >> B[i];
        a += A[i];
        b += B[i];
        get[i] = A[i]*2 + B[i];
    }
    ll sub = a;
    sort(get.begin(),get.end());
    ll ans = 0;
    while(sub >= 0){
        sub -= get[N-ans-1];
        ans++;
    }
    cout << ans << endl;
}
