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

struct node {
	long long a, b;
	node() { cin >> a >> b; }
	bool operator < ( const node& f ) const
	  { return a * 2 + b > f.a * 2 + f.b; }
};

int main() {
	int n; cin >> n;
	vector<node> V;
	long long all = 0;
	for( int i = 1; i <= n; i ++ ) V.push_back( node() );
	sort( V.begin(), V.end() );
	for( auto c : V ) all += c.a;
	int ans = 0;
	for( auto c : V ) {
		if( all < 0 ) return cout << ans, 0;
		ans ++; all -= c.a * 2 + c.b;
	}
	cout << ans;
	return 0;
}
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
  ll ans = 0;
  int N; cin >> N;
  vector<ll> A(N),B(N);
  ll aoki = 0 , takahashi = 0;
  for(int i=0; i<N; i++){
    cin >> A[i] >> B[i];
    aoki += A[i];
//    takahashi += B[i];
  }
  
  vector<ll> value(N);
  for(int i=0; i<N; i++){
    value[i] = 2*A[i]+B[i];
  }
  sort(value.begin(), value.end());
  reverse(value.begin(), value.end());
  for(int i=0; i<N; i++){
    takahashi += value[i];
    ans ++;
    if( takahashi > aoki ) break;
  }
  cout << ans;
}