#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
    #include <atcoder/all>
    using namespace atcoder;
#endif

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<string>;
using vin= vector<int>;
using ll=long long;
using ull=unsigned long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using P=pair<int ,int>;
//const long double pi=acos(-1);
#define ft first
#define sd second
#define fn front
#define pb push_back
#define eb emplace_back
#define it insert
#define si(v) int((v).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sot(x) sort(x.begin(), x.end())
#define rese(x) reverse(x.begin(), x.end())
#define vnn(x,y,s,name) vector<vector<int>> name(x, vector<int>(y,s))
#define mse(x) memset(x, 0, sizeof(x))
#define mii(x,y,z) min(x,min(y,z))
#define maa(x,y,z) max(x,max(y,z))
#define cps CLOCKS_PER_SEC
#define yes cout<<"Yes"<<"\n"
#define no cout<<"No"<<"\n"
#define cset(x) cout<<fixed<<setprecision(x)
//const int INF=1001001001;
//998244353  1000000007


int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<long long> ax(n);
    long long as=0;
    rep(i,n){
        ll a,b;
        cin>>a>>b;
        as-=a;
        ax[i]=2*a+b;
    }
    sot(ax);
    rese(ax);
    int cnt=0;
    while(as<=0){
        as+=ax[cnt];
        cnt++;
    }
    cout<<cnt<<endl;
}



















#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pi pair<int, int>
#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define FIO ios_base::sync_with_stdio(0), cin.tie(0)
#define fi first
#define se second

signed main() {
    FIO;
    int n;
    cin >> n;
    set<pair<int, string>> v;
    for (int i = 0; i < n; i++) {
        string s;
        int t;
        cin >> s >> t;
        v.insert({-t, s});
    }
    auto it = v.begin();
    it++;
    cout << ((*it).se);
}
