#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<numeric>
//#include<atcoder/scc>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
    int n; cin >> n;
    vector<ll> a(n),b(n);
    rep(i,n) cin >> a[i] >> b[i];
    vector<ll> c(n);
    rep(i,n) c[i] = a[i]*2+b[i];
    ll sum = 0;
    rep(i,n) sum += a[i];
    sort(c.rbegin(),c.rend());
    ll now = 0;
    rep(i,n){
        now += c[i];
        if(now > sum){
            cout << i+1 << endl;
            return 0;
        }
    }   
}



#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2005;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    ll cnt = 0;
    vector<ll>v(n);
    for(int i = 0; i < n; i++)
    {
        ll x, y;
        cin >> x >> y;
        cnt -= x;
        v[i] = 2 * x + y;
    }
    sort(v.begin(), v.end());
    int ans = 0;
    while(cnt <= 0)
    {
        cnt += v.back();
        v.pop_back();
        ans++;
    }
    cout << ans << endl;
    return 0;
}