        // Rakib (CSE'19)
                        
        #include<bits/stdc++.h>
        #include<iostream> 
        #include<queue> 
        #include<stack> 
        #include<set> 
        #include<iomanip> 
        #include<iterator> 
        #include<sstream>
        #include<algorithm> 
        #include<vector> 
        #include<string> 
        #include<cstdlib> 
        #include<cmath> 
        #include<map> 
                        
        #define               boost_                 ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
        #define               pb                     push_back
        #define               read(i,n,a)            for(i=0;i<n;++i) cin>>a[i]
        #define               print(i,a)             for(auto i:a) cout<<i<< " " ; cout<<endl ;
        #define               dpoint(n)              cout<<showpoint<<fixed<<setprecision(n)
        #define               MOD                    1000000007
        #define               llmax                  LONG_LONG_MAX
        #define               llmin                  LONG_LONG_MIN
        #define               read_grid(i,j,n,m,a)   for(i=0;i<n;++i) for(j=0;j<m;++j) cin >> a[i][j];
        #define               all(a)                 a.begin(),a.end()
        #define               vl                     vector<ll>
        #define               MP                     make_pair
                        
        typedef               long long              ll;
        typedef               unsigned long long     ull;
                        
        using namespace std;
                
        int gcd(int x,int y){
                if(!y) return x;
                return gcd(y,x%y);
        }

        /*ll MX=100001;
        //vector<ll>check(MX,1), divisor(MX,2);
        //vector<ll>primes,divisor;
                        
        void prime(){
                        
                ll i,j;                                                         
                //check[1]=0;
                //check[2]=1;
                //primes.pb(2);
                for(i=3;i<MX;i+=2){
                        if(check[i]){
                                //primes.pb(i);
                                divisor[i]=i;
                                for(j=i*i;j<MX;j+=2*i) divisor[j]=i, check[j]=0; 
                        }
                }
        } */
        
        ll power_mod(ll b,ll p){
                
                ll ans=1;
                b%=MOD; //if b>MOD;
                if(!b) return 0 ;
                while(p){
                        if(p%2) ans=(ans*b)%MOD;
                        p>>=1; // top to bottom
                        b=(b*b)%MOD; // bottom to top
                } 
                
                return ans;
        }

        bool cmp(const pair<ll,ll> &a, const pair<ll,ll> &b){ return 2*a.first+a.second>2*b.first+b.second; }
                
        void task(ll case_no){

                ll n;
                cin >> n;
                vector<pair<ll,ll>>a;

                ll sum=0,cnt=n;
                while(n--){
                        ll x,y;
                        cin >> x >> y;
                        a.pb({x,y});
                        sum+=x;
                }

                sort(all(a),cmp);

                ll sum1=0,i;
                
                for(i=0;i<a.size();++i){
                        
                      sum1+=a[i].first +a[i].second;
                      sum-=a[i].first;
                      if(sum1>sum) break;

                }

                cout << i+1  << "\n";

        }
                        
        int main(){
                                
                boost_;
                
                //prime();
                ll t=1,i=0;
                //cin >> t;
                
                while(t--){
                
                        task(++i);
                        
                }
                        
                return 0;
        }
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

struct edge {int to, cost; };

int main(){
  int n;
  cin >> n;
  ll sa = 0;
  ll delta[n];
  for(int i=0; i<n; i++){
    ll a, b;
    cin >> a >> b;
    sa += a;
    delta[i] = 2*a+b;
  }
  sort(delta, delta+n, greater<ll>());
  int ans = 0;
  for(int i=0; i<n; i++){
    if(sa<0) break;
    sa -=  delta[i];
    ans++;
  }
  cout << ans << endl;
}