//#include<bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <string.h>
#include <vector>
#include <utility>
#include <map>
 
//#pragma GCC optimize "trapv"
 
#define int long long
#define For(i,a,b) for(int  i=a;i<b;i++)
 
#define pb push_back
#define endl "\n"
 
#define F first
#define S second
 
#define dracarys ios_base::sync_with_stdio(false);cin.tie(NULL)
#define all(v) v.begin(),v.end()
 
#define TEST_CASE int  t;cin>>t;while(t--)
#define debug(...) cout<<#__VA_ARGS__<<" = "; print(__VA_ARGS__);
 
using namespace std;
const int MOD = 1e9 + 7;
 
void print()  {    cout<<endl;  }
void printArray()  {    return;  }
void read() { return; }
 
template<typename T , typename... Args>  void print(T a , Args... arg)    {    cout << a << " " ;    print(arg...);    }
 
template<typename T , typename... Args> void read(T &a , Args&... arg) {   cin >> a;   read(arg...);   }
 
template<typename T,typename... Args> void read(vector<T>&v , Args&... arg) {  for(auto &i : v)  cin>>i;  read(arg...);  }
 
template<typename T,typename... Args> void printArray(vector<T>&v, Args&... arg) {   for(auto i : v)     cout<<i<<" ";   cout<<endl;  printArray(arg...);    }
 
int power(int a,int b) { int  res=1; while(b) { if(b&1LL) res=res*a; b>>=1LL; a=a*a; } return res; }
 
int modPower(int a,int b) { int res=1; while(b) { if(b&1L) res=(res%MOD*a%MOD)%MOD; b>>=1; a=(a%MOD*a%MOD)%MOD; } return res; }
 
int gcdExtended(int a,int b,int *x,int *y){ if(a==0) { *x=0,*y=1; return b; } int x1,y1; int gcd=gcdExtended(b%a,a,&x1,&y1); *x=y1-(b/a)*x1; *y = x1; return gcd; }
 
int modInverse(int b,int m) {int x,y; int g=gcdExtended(b,m,&x,&y); if (g != 1) return -1; return (x%m + m) % m; }
 
int modDivide(int a,int b,int m=MOD) { a=a%m; int inv=modInverse(b,m); if(inv==-1) return -1; else return (inv*a)%m; }
 
 
void runCase_()
{
        int n; read(n);
        vector<pair<int,int>>v(n);
        for(auto &i : v) read(i.F,i.S);
        int aoki = 0,taka = 0,ans = 0;
        for(auto i : v) aoki += i.F;
        sort(all(v),[](pair<int,int>a,pair<int,int>b)
             {
                     return 2*a.F + a.S > 2*b.F + b.S;
             });
        int i = 0;
        while(i < n && taka <= aoki)
        {
                taka += (v[i].F + v[i].S);
                aoki -= v[i].F;
                ++ans,++i;
        }
        print(ans);
}
 
 
signed main()
{
     dracarys;
//      TEST_CASE
     runCase_();
     return 0;
}
 
/** TEST CASES HERE **/
/*
 
*/
#include "bits/stdc++.h"
#define pb push_back
#define mp make_pair

using namespace std;

using ll = long long;

signed main(){
	ll n;
	cin >> n;

	vector<ll>a(n),b(n);
	ll sum = 0;

	vector<pair<ll,pair<ll,ll>>>d;
	
	for(ll i=0;i<n;i++){
		cin >> a[i] >> b[i];
		sum = sum + a[i];
		d.pb(mp(-2*a[i]-b[i],mp(a[i],a[i]+b[i])));
	}

	sort(d.begin(),d.end());

	ll c = 0;
	ll cnt = 0;

	for(auto u : d){
		//cout << u.first << " " << u.second.first << " " << u.second.second << "\n";
		if(sum < c){
			break;
		}
		else{
			sum = sum-u.second.first;
			c = c + u.second.second;
			cnt++;
		}
	}

	cout << cnt << "\n";

	return 0;
}