#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
const int N = 2e5 + 7;

struct Node {
	LL a, b;
} in[N];

bool cmp(Node o1, Node o2) {
	return (2 * o1.a + o1.b) > (2 * o2.a + o2.b);
}

int main(void) {
	int n;
	LL sa = 0, sb = 0;
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> in[i].a >> in[i].b;
		sa += in[i].a;
	}
	
	sort(in + 1, in + n + 1, cmp);
	for (int i = 1; i <= n; ++i) {
		LL a = in[i].a, b = in[i].b;
		sa -= a;
		sb += a + b;
		if (sb > sa) {
			cout << i;
			return 0;
		}
	}
	
	return 0;
}











#include <bits/stdc++.h>
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) rep2(i,0,n)
#define rep1(i,n) rep2(i,1,n+1)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
ll n,a[222222],b,ans=0,l=-1,r;
int main()
{
	cin>>n;
	r=n;
	a[0]=0;
	rep1(i,n)
	{
		cin>>b>>a[i];
		ans+=b;
		a[i]+=b*2;
	}
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	rep1(i,n) a[i]+=a[i-1];
	while(l<r-1)
	{
		ll mid=(l+r)/2;
		if(a[mid]>ans) r=mid;
		else l=mid;
	}
	re(r)
	return 0;}