#include<bits/stdc++.h>
using namespace std;
#define light ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pb push_back
#define cases() ll t;cin>>t;while(t--)
#define all(c) c.begin(),c.end()
#define PI 3.14159265358979323846
const ll MAX = 2e5+5;
const ll INF = 1e18;
const ll MOD = 1e9+7;

int main()
{
    ll i,j,k,l,p,q,x,y,n;
    cin >> n;
    multiset<pair<ll,pair<ll,ll>>> mp;
    p = 0;
    for(i=0;i<n;i++)
    {
        cin >>  x >> y;
        mp.insert({2*x+y,{x,y}});
        p+=x;
    }
    l = 0;k = 0;
    while(l<=p)
    {
        pair<ll,ll> pi = mp.rbegin()->second;
        x = pi.first;y = pi.second;
        p = p-x;l = l+x+y;
        k++;
        mp.erase(prev(mp.end()));
    }
    cout << k;
}
//#pragma GCC optimize(2)
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<cmath>
#include<cctype>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<sstream>
#include<ctime>
#include<cstdlib>
#define X first
#define Y second
#define L (u<<1)
#define R (u<<1|1)
#define pb push_back
#define mk make_pair
#define Mid (tr[u].l+tr[u].r>>1)
#define Len(u) (tr[u].r-tr[u].l+1)
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define db puts("---")
using namespace std;

//void rd_cre() { freopen("d://dp//data.txt","w",stdout); srand(time(NULL)); }
//void rd_ac() { freopen("d://dp//data.txt","r",stdin); freopen("d://dp//AC.txt","w",stdout); }
//void rd_wa() { freopen("d://dp//data.txt","r",stdin); freopen("d://dp//WA.txt","w",stdout); }

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;

const int N=200010,mod=1e9+7,INF=0x3f3f3f3f;
const double eps=1e-6;

int n;
struct Node
{
    LL a,b;
    bool operator < (const Node&W) const
    {
        return a*2+b>W.a*2+W.b;
    }
}node[N];

int main()
{
//	ios::sync_with_stdio(false);
//	cin.tie(0);

    scanf("%d",&n);
    LL sum=0,ans=0;
    for(int i=1;i<=n;i++) scanf("%lld%lld",&node[i].a,&node[i].b),sum+=node[i].a;
    sort(node+1,node+1+n);
    int res=0;
    for(int i=1;i<=n;i++)
    {
        ans+=node[i].a*2+node[i].b;
        res++;
        if(ans>sum) break;
    }
    printf("%d\n",res);




















	return 0;
}
/*

*/








