#include <bits/stdc++.h>
using namespace std;

int main(){
  long long N;
  cin >> N;
  
  long long Sa=0;
  vector<long long> V(N);
  for(int i=0;i<N;i++){
    long long a,b;
    cin >> a >> b;
    Sa += a;
    V[i] = a*2+b;
  }
  sort(V.rbegin(),V.rend());
  
  for(int i=0;i<=N;i++){
    if(Sa<0){
      cout << i << endl;
      return 0;
    }
    Sa -= V[i];
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll,ll>;
using pld = pair<ld,ld>;
using vll = vector<ll>;
using vld = vector<ld>;
#define _GLIBCXX_DEBUG
#define rep(j, m) for (ll j = 0; j < (ll)(m); j++)
#define rep2(i, l, n) for (ll i = l; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
const ld PI = 3.1415926535897932;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;


int main() {
	ll N;
	cin >> N;
	ll sum = 0;
	vll V(N);
	rep(i,N) {
		ll a;
		ll b;
		cin >> a >> b;
		sum += a;
		V[i] = 2*a + b;
	}
	sort(all(V));
	reverse(all(V));
	ll sum2 = 0;
	rep(i,N) {
		sum2 += V[i];
		if (sum2 > sum) {cout << i + 1 << endl;break;}
	}
}
