    /* Great things never come from comfort zones,
    "whatever the mind of a man can conceive and believe,it can achieve." */
     
    #include <bits/stdc++.h>
    using namespace std;
 
    void my_dbg() { cout << endl; }
    template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
    { cout << ' ' << A; my_dbg(B...); }
    #define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)
 
    #define ll long long
    #define dd double
    #define scf(n) scanf("%d",&n)
    #define lscf(n) scanf("%lld",&n)
    #define lpri(n) printf("%lld ",n)
    #define pri(n) printf("%d ",(int)n)
    #define prin(n) printf("%d\n",(int)n)
    #define lprin(n) printf("%lld\n",n)
    #define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
    #define show(a) for(auto xy: a) pri(xy); printf("\n");
 
    #define pb push_back
    #define mp make_pair
    #define F first
    #define S second
    #define all(x)     x.begin(),x.end()
    #define SET(a,b) memset(a,b,sizeof(a))
    #define tc   int tt; scf(tt); while(tt--)
 
    #define inf INT_MAX
    #define ninf INT_MIN
    #define gcd __gcd
    #define bitcount(n) __builtin_popcount(n)
 
    const int mod=1e9+7;
    const int N = 1e6+7;

    int pos[N];

    int main()
    {
        int n; scf(n);

        vector<ll>a(n),b(n);

        vector<int>ind(n);

        iota(all(ind),0);// iterates and fill with increaing values
                        //0 1 2 3 4.......


        ll A=0,B=0,tmp;

        rep(i,0,n)
        lscf(a[i]),lscf(b[i]);

        sort(all(ind),[&](const int &i , const int &j)
        {
            return (2*a[i]+b[i]>2*a[j]+b[j]);
        }); // net effect 2*a[k] + b[k] in town of speech 

        A=accumulate(all(a),0ll);

        int c=0,d=0;

        rep(i,0,n)
        {
            if(B>A)
            break;

            c++;

            int j=ind[i];

            B+=b[j]+a[j];

            A-=a[j];
        }

        prin(c);

    }
#include <bits/stdc++.h>
using namespace std;

int main() {
  
  //Nの入力
  long N=0;
  cin >> N;
  
  //町の青木派と高橋派を入力
  int64_t A[N],B[N],Total[N];
  int64_t sum_A = 0;
  int64_t sum_B = 0;
  
  //それぞれの派の合計
  for(long i=0; i<N; ++i){
    cin >> A[i] >> B[i];
    Total[i] = 2*A[i] + B[i];
    sum_A += A[i];
    sum_B += B[i];
  }
  
  //cout << "sum_A:" << sum_A << endl;
  //cout << "sum_B:" << sum_B << endl;
  
  long count = 0;
  
  std::sort(Total, Total+N, std::greater<>());
  //for(long i=0; i<N; ++i) cout << Total[i] << endl;
  
  long temp_sum = 0;
  for(long i=0; i<N; ++i){
    //cout << A[i] << endl;
    temp_sum += Total[i];
    count++;
    if(sum_A < temp_sum)break;
  }

  cout << count << endl;

}