#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <map>
#define for1(x,y) for(long long x = 1; x<ll(y); x++)
#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
#define PII pair<int,int>
#define FF first
#define SS second
#define PB push_back
#define all(x) x.begin(), x.end()
 
#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
using namespace std;
 
//Errichto Orz debug template
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
 
// ends debug
 
// aliases
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using ld = long double;
 
 
#define vi vector<int> 
#define vl vector<ll> 
#define pb(x) push_back(x)
const double EPS = (1e-7), EPSm= (1e7);
const ll linf = (ll)1e17 + 5;
long double PI = 3.14159265359;
int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{-1,-1},{1,1},{-1,1},{1,-1}};
	
const int MAXN = 1e5+10;
const int NINF = -1e5;
const int INF = 20000000;
const ll MOD = 1e9+7;
 
	
// Mathematical functions.
 
int GCD(int a, int b)	
{
	if (!b)
		return a;
	return GCD(b, a % b);
}
 
int LCM(int a, int b)
{
	return (a * b) / GCD(a, b);
}
 
int modpow(int x, int n, int m = MOD)
{
	if (n == 0) return 1 % m;
	long long u = modpow(x, n / 2, m);
	u = (u * u) % m;
	if (n % 2 == 1)
		u = (u * x) % m;
	return u;	
}
 
/**
 * m should be prime
 */
int modinv(int x, int m = MOD)
{
	return modpow(x, m - 2, m);
}
 
//////////////////// START CODE HERE ///////////////////////////

bool cmp(array<ll,2> a,array<ll,2> b){
	return 2*a[0]+a[1]>2*b[0]+b[1];
	
}

void solve()
{	  
	int n;
	cin>>n;
	vector<array<ll,2>> v(n);
	ll cnt1=0,cnt2=0;
	forn(i,0,n){
		cin>>v[i][0]>>v[i][1];
		cnt2+=v[i][0];
	}
	sort(all(v),cmp);
	int i=0,ans=0;
	while(cnt1<=cnt2 && i<n){
		cnt1+=v[i][0];
		cnt1+=v[i][1];
		cnt2-=v[i][0];
		i++;
		ans++;
	}
	//cout<<ans<<endl;
	cout<<ans<<endl;
	return;
}
 
 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int test;
	//cin >> test;
	//while(test--)
		solve();
	return 0;
}

// D - Choose Me
// 模範解答
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using st = string;
using Pii = pair<int, int>;
using Cd = complex<double>;
#define rep2(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) rep2(i, 0, n)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

#define INF 1 << 30
#define RE0 return 0

const int mod = 1e9 + 7;
const int di[4] = {0, 1, 0, -1};
const int dj[4] = {1, 0, -1, 0};

const int di2[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj2[8] = {1, 0, -1, 0, 1, -1, 1, -1};

int main() {
  int n;
  cin >> n;
  vector<pair<ll, pair<ll, ll>>> v(n);
  // .first: 高橋氏がその町に演説に行くことで得られる票数 
  // .second.first: その町の青木派 
  // .second.second: その町の高橋派

  for(int i = 0; i < n; i++) {
    cin >> v.at(i).second.first >> v.at(i).second.second;
    v.at(i).first = v.at(i).second.first + v.at(i).second.first + v.at(i).second.second;
  }
  ll aokisum = 0;
  ll takahashisum = 0;
  for(int i = 0; i < n; i++) {
    aokisum += v.at(i).second.first;
  }
  // cout << endl;
  // cout << aokisum << endl;
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  int cnt = 0;
  for(int i = 0; i < n; i++) {
    takahashisum += v.at(i).second.first + v.at(i).second.second;
    aokisum -= v.at(i).second.first;
    // cout << takahashisum << " " << aokisum << endl;
    if(takahashisum <= aokisum) cnt++;
    else {
      cnt++;
      break;
    }
  }
  cout << cnt << endl;
  RE0;
}