#define ll long long
#define dd long double
#define pb push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define fo(i ,a, n) for(ll i =a ; i < n ; i++)
//#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)//traverse through a dataset
//#define sortx(x) sort(all(x))
#define maxpq priority_queue<ll>
#define minpq priority_queue<ll,vector<ll>,greater<ll>>
#include<bits/stdc++.h>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<utility>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<bitset>
ll fact[200001] ;
ll inf=1e18;
ll z=1e9+7;
ll gdp(ll a , ll b){return (a - (a%b)) ;}
ll ld(ll a , ll b){if(a < 0) return -1*gdp(abs(a) , b) ; if(a%b == 0) return a ; return (a + (b - a%b)) ;} // least number >=a divisible by b
ll gd(ll a , ll b){if(a < 0) return(-1 * ld(abs(a) , b)) ;    return (a - (a%b)) ;} // greatest number <= a divisible by b
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
ll e_gcd(ll a , ll b , ll &x , ll &y){ if(b > a) return e_gcd(b , a , y , x) ; if(b == 0){x = 1 ; y = 0 ; return a ;}
ll x1 , y1 ; e_gcd(b , a%b , x1 , y1) ; x = y1 ; y = (x1 - ((a/b) * y1)) ; return e_gcd(b , a%b , x1 , y1) ;}
ll power(ll a ,ll b , ll p){if(b == 0) return 1 ; ll c = power(a , b/2 , p) ; if(b%2 == 0) return ((c*c)%p) ; else return ((((c*c)%p)*a)%p) ;}
ll inverse(ll a ,ll n){return power(a , n-2 , n) ;}
ll max(ll a , ll b){if(a > b) return a ; return b ;}
ll min(ll a , ll b){if(a < b) return a ; return b ;}
ll left(ll i){return ((2*i)+1) ;}
ll right(ll i){return ((2*i) + 2) ;}
ll ncr(ll n , ll r){if(n < r|| (n < 0) || (r < 0)) return 0 ; return ((((fact[n] * inverse(fact[r] , z)) % z) * inverse(fact[n-r] , z)) % z);}
void swap(ll&a , ll&b){ll c = a ; a = b ; b = c ; return ;}
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define ub(v,x) upper_bound(v.begin(),v.end(),x);
#define lb(v,x) lower_bound(v.begin(),v.end(),x);
dd pi = acos(-1) ;
ll pow(ll a ,ll b ){if(b == 0) return 1 ; ll c = pow(a , b/2) ; if(b%2 == 0) return (c*c) ; else return ((c*c)*a);}

using namespace std ;
const int N = 2e5+7;
const int M=1e6+7;
//vector<ll>adj[N];
//int mat[N][N];
//vector<bool>used(N,false);
//vector<ll>d(N,-1);
//vector<ll>p(N,-1);

bool cmp(ll a,ll b){
   return a>b;
}

struct S
{
    int m_n1;
    int m_n2;
    int m_n3;

    S(int n1, int n2, int n3) : m_n1(n1), m_n2(n2), m_n3(n3)
    {
    }

    bool operator<(const struct S& other) const
    {
        if(m_n1!=other.m_n1)
        return m_n1 < other.m_n1;
        else
        return m_n2 > other.m_n2;
    }
};




void solve(){
  ll n;
  cin>>n;
  ll votes[n][2];
  ll s[2]={0};
  vector<pair<ll,pair<ll,ll>>>v;
  fo(i,0,n){
    ll x,y;
    cin>>x>>y;
    votes[i][0]=x;
    votes[i][1]=y;
    s[1]+=x;
    v.pb({y+2*x,{x,y}});
  }
ll cnt=0;
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
 fo(i,0,n){
    if(s[0]>s[1]){
       break;
    }
    else{
      s[0]+=(v[i].S.F+v[i].S.S);
      s[1]-=v[i].S.F;

      cnt++;
    }
 }

 cout<<cnt<<endl;
}

  
    
int main()
{
      #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
      ios_base::sync_with_stdio(false);
     cin.tie(NULL);
   
    ll t;
    //cin>>t;
    t=1;
    while(t--){
    solve();
     }
  }
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  vector<ll> a(n),b(n); rep(i,n) cin >> a[i] >> b[i];
  ll sum = 0;
  vector<pair<ll,int>> s(n);
  rep(i,n){
    ll k = 0;
    k = a[i]+b[i];
    sum += k;
    k += a[i];
    s[i] = make_pair(k,i);
  }
  sort(s.begin(),s.end());
  
  ll t = 0;
  int m = 0;
  rep(i,n){
    ll aa;
    ll ss = s[i].first-a[s[i].second];
    aa = ss-b[s[i].second];
    
    if(sum-ss <= t+aa) break;
    sum -= ss;
    t += aa;
    m++;
  }

  int ans = n-m;

  cout << ans << endl;
  
  return 0;
}
