/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
bool flag[19999990];
int _prime[19999990];
void get_prime(int maxn)
{
    int i,j;
    for(i=2;i<=maxn;i++)
        if(!flag[i])
        {
            _prime[++_prime[0]]=i;
            for(j=i*i;j<=maxn;j+=i)
                flag[j]=true;
        }
}
long long _do[400001],n_do[400001];
long long aoki[1000000],ta[1000000];
int main()
{
	long long n;
	cin>>n;
	long long i;
	long long ao=0;
	for(i=0;i<n;i++){
		cin>>aoki[i]>>ta[i];
		_do[i]=aoki[i]+ta[i];
		n_do[i]=aoki[i];
		ao-=n_do[i];
		_do[i]=_do[i]+n_do[i];
	}
	sort(_do+0,_do+n);
	long long g=0;
	for(i=n-1;i>=0;i--){
		if(ao<=0){
			ao+=_do[i];
			g++;
		}
		else{
			break;
		}
	}
	if(ao>0) cout<<g<<endl;
	return 0;
}

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization("unroll-loops")

#include "bits/stdc++.h"
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'
#define F first
#define S second
#define IO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define cf ll testcases;cin>>testcases;while(testcases--)
#define prn(x) if(x) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define minel(x) (*min_element(all(x)))
#define maxel(x) (*max_element(all(x)))
#define cou dbg=1;cout
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
typedef vector<ld> vd;
typedef vector<pi> vp;
ll dbg=0;
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p);
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p);
template<typename A> istream& operator>>(istream& cin, vector<A> &v);
int dx[] = {-1, -1, -1,  0, 0,  1, 1, 1};
int dy[] = {-1,  0,  1, -1, 1, -1, 0, 1};

void solve(){
    ll n;
    cin>>n;
    vp arr(n);
    ll sum=0;
    for(ll i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        arr[i]={2*a+b,a};
        sum+=a;
    }
    sort(all(arr),greater<pair<ll,ll>>());
    ll ans=0;
    ll sum2=0;
    for(auto i:arr){
        if(sum2>sum) break;
        sum2+=i.F-i.S;
        sum-=i.S;
        ans++;
    }
    cout<<ans<<endl;
}

int main(){
    IO;
    // cf
    solve();
    return 0;
}


template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { 
    if(dbg){dbg=0;
        return cout << "(" << p.F << ", " << p.S << ")"; 
    }else{
        return cout<<p.F<<' '<<p.S;
    }
        }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
    if(dbg){dbg=0;
        cout << "["; for(ll i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
    }else{
        for(ll i=0;i<v.size()-1;i++) cout<<v[i]<<' ';
        return cout<<v[v.size()-1];
    }
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
   cin >> p.first;
   return cin >> p.second;
}
template<typename A> istream& operator>>(istream& cin, vector<A> &v) {
   for(ll i=0;i<v.size()-1;i++) cin>>v[i];
   return cin >> v[v.size()-1];
}