#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
    ll n, a, b, i, sum = 0;
    cin>>n;
    vector<ll> arr(n);
    for(i=0;i<n;i+=1)
    {
        cin>>a>>b;
        arr[i] = 2*a+b;
        sum+=a;
    }
    sum = -sum;
    sort(arr.begin(), arr.end(), greater<ll>());
    i = 0;
    while(sum<=0)
    {
        sum+=arr[i];
        i+=1;
    }
    cout<<i<<endl;
}

#include<bits/stdc++.h>
using namespace std;
using ll=int64_t;
ll c,x;vector<ll>v;
int main(){
    ll n;cin>>n;vector<vector<ll>>s(n,vector<ll>(2));
    for(int i=0;i<n;i++){
        for(int j=0;j<2;j++)cin>>s[i][j];
        x+=s[i][0];
        v.push_back(2*s[i][0]+s[i][1]);
    }
    sort(v.begin(),v.end());reverse(v.begin(),v.end());
    for(int i=0;i<n;i++){if(x>=0){c++;x-=v[i];}else break;}
    cout<<c<<endl;
}
