#include<bits/stdc++.h>
using namespace std;
struct node{long long x,y;}f[200002];
long long n,a=0,b=0,cnt=0;
bool cmp(node x,node y){return 2*x.x+x.y>2*y.x+y.y;}
int main(){
    scanf("%lld",&n);
    for(int i=0;i<n;++i)scanf("%lld%lld",&f[i].x,&f[i].y),a+=f[i].x;
    sort(f,f+n,cmp);
    while(b<=a){b+=f[cnt].x+f[cnt].y;a-=f[cnt].x;++cnt;}
    printf("%lld",cnt);
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define R(i,b,a) for(int i=(int)(b);i>=(int)(a);i--)
#define endl "\n"
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<x<<endl,exit(0)
#define pii pair<int,int>
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second

//implementation mistakes:

//binary search on unsorted array
//1 to 2e5 instead of 0 to 4e5 (bounds)
//writing mnn=min(mn,value)
//writing n instead of m in bounds
//forgot to mod at every step since ai<1e18 and sum would exceed limits
//declared the using the global empty string instead of local string

//forgot to take input k
//intrepreted the question wrongly

//wrinting i instead of w[i]
//if instead of else if  -swapping two times
//printing ans without calculating it :):):)

int32_t main(){
   ios;
   int n;
   cin>>n;

   int sum=0;
   vector <int> v;

   F(i,1,n){
   	int a,b;
   	cin>>a>>b;
   	sum-=a;
   	v.pb(2*a+b);
   }
   sort(all(v));
   reverse(all(v));

   if(sum>0) out(0);
   F(i,0,n-1){
   	sum+=v[i];
   	if(sum>0) out(i+1);
   }
}
