#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'
#define f first
#define s second
#define ub  upper_bound
#define lb  lower_bound
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define fbo find_by_order 
#define ook order_of_key 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << "[" << name << " : " << arg1 << "]" << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cerr << "[";
cerr.write(names, comma - names) << " : " << arg1<<"] | ";__f(comma+1, args...);
}

using ld = long double;
using ll = long long;
using pii = pair <int,int>;
using pll = pair <ll,ll>;
using vi = vector <int>;
using vll = vector <ll>;
using vpii = vector <pii>;
using vpll = vector<pll>;
using vs = vector <string>;


int main(){
  fastio;

  int n;
  cin >> n;
  
  vll a(n), b(n);
  vi id(n);

  ll va = 0, vb = 0;
  for(int i=0;i<n;i++)
    cin >> a[i] >> b[i], id[i] = i, va += a[i];

  sort(all(id),[&](auto i, auto j){
    return (2*a[i]+b[i] > 2*a[j]+b[j]) or ((2*a[i]+b[i] == 2*a[j]+b[j]) and a[i] > a[j]);
  });

  int ans = 0;
  for(int x:id){
    if(vb > va) break;
    ans++;
    vb += (a[x]+b[x]);
    va -= a[x];
  }

  cout << ans << endl;
  
  return 0;
}
#include<iostream> 
#include<algorithm> 
#include<vector> 
#include<string> 
#include<cstdlib> 
#include<cmath> 
#include<map> 
#include<queue> 
#include<stack> 
#include<set> 
#include<iomanip> 
#include<iterator> 
#include<sstream>
using namespace std;
int main()
{
    long long n,a,b,ta,ao,i,k,l;
    vector<pair<long long,long long> >v;
    cin>>n;
    ta=ao=0;
    while(n--)
    {
        cin>>a>>b;
        v.push_back(make_pair(((2*a)+b),a));
        ao+=a;
    }
    sort(v.begin(),v.end(),greater<pair<long long,long long> >());
    k=l=0;
    for(i=0;i<v.size();i++)
    {
        k+=(v[i].first-v[i].second);
        l+=v[i].second;
        if(k>(ao-l))
        {
            cout<<i+1<<endl;
            break;
        }
    }
    return 0;
}
