#include<bits/stdc++.h>
using namespace std;
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<utility>
#define ll long long int
#define speed ios_base::sync_with_stdio(false);cin.tie(0);
#define pb push_back
#define pf push_front
#define mod 1000000007
#define ff first
#define ss second
#define ld long double
 
#define lp(i,a,b) for(ll i=a ; i<b ; i++)
#define rlp(i,a,b) for(ll i=b ; i>=a ; i--)
 
// ---------------------------------
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
// -----------------------------------
 bool cmp(pair<long long int, long double> a, pair<long long int,long  double> b)
{
	if (a.second == b.second)
		return a.first < b.first;
	return a.second > b.second;
}

ll power(ll x,ll y,ll p)
{
	ll res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		{
			res=(res*x)%p;
		}
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
ll modInverse(ll n,ll p)
{
	return power(n,p-2,p);
}
ll factorial(ll n)
{
    if(n==0)
    {
        return 1;
    }
    else if(n==1)
    {
        return 1;
    }
    else
    { 
        return factorial(n-1)*n;
    }
}
ll nCr(ll n, ll r, ll p)
{
	if(r==0) 
	{
		return 1;
	}
	ll fac[n+1];
	fac[0]=1;
	for(ll i=1 ; i<=n ; i++)
	{
		fac[i]=fac[i-1]*i%p;
	}
	return (fac[n]*modInverse(fac[r],p)%p*modInverse(fac[n-r],p)%p)%p;
}
bool sortbysec(const pair<pair<ll,ll>,ll> &a, 
              const pair<pair<ll,ll>,ll> &b) 
{ 
    return (a.second < b.second); 
} 

int main()
{
	ll n;
	cin>>n;
	vector< pair<pair<ll,ll>,ll>> v;
	ll sa=0,st=0;
	lp(i,0,n)

	{
		ll x,y;
		cin>>x>>y;
		pair<ll,ll>p=make_pair(x,y);
		ll s;
		s=2*x+y;
		v.push_back(make_pair(p,s));
		sa+=x;
	}
	// ll val=sa;
	sort(v.begin(),v.end(),sortbysec);
	ll ans=0;
	for(ll i=v.size()-1;i>=0;i--)
	{
		// cout<<v[i].second<<endl;
		sa=sa-v[i].first.first;
		st+=v[i].first.first +v[i].first.second;
		ans++;
		if(st>sa)
			break;
	}
	
	// cout<<ans<<endl;
	// cout<<ans2<<endl;
	 // ll t;
	 // scanf("%lld",&t);
	 // while(t--)
	 // {
	 // 	ll ans=0;
	 	
	 	cout<<ans<<endl;
	 // }
	 return 0;

}
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<ll> vll;
 
#define all(v) v.begin(),v.end()
#define test() int t;cin>>t;while(t--) 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ff first
#define ss second
#define pb push_back
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod = (int)1e9+7;
const int INF = (int)1e9;

int main()
{
	int n;
	cin>>n;
	vector<ll> store(n);
	ll diff = 0;
	for(int i = 0; i<n; i++)
	{
		ll a, b;
		cin>>a>>b;
		diff-=a;
		store[i]=2*a+b;
	}
	int i;
	sort(all(store), greater<ll>());
	for(i = 0; i<n; i++)
	{
		diff+=store[i];
		if(diff>0)break;
	}
	cout<<i+1<<endl;
}   