#include<bits/stdc++.h>

using namespace std;

using ll = long long int;
struct Sum {
  ll a;
  ll b;
  ll s;
};

int main() {
  int n;
  cin >> n;
  vector<Sum> s(n);
  ll sumA = 0, sumT = 0;
  for(int i=0; i<n; i++) {
    ll a, b;
    cin >> a >> b;
    sumA += a;
    sumT += b;
    s[i] = Sum{a, b, 2*a + b};
  }
  sort(s.begin(), s.end(), [](Sum a, Sum b) {
    return (a.s == b.s) ? (a.a > b.a) : (a.s > b.s);
  });

  ll ptA = sumA, ptT = 0;
  ll cnt = 0;
  for(auto x : s) {
    ptT += x.s - x.a;
    ptA -= x.a;
    cnt++;
    if(ptT > ptA) break;
  }
  cout << cnt << endl;
}
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
ll mod = 1000000007;
ll inf = 1e18;
int main(){

    int n;
    cin >> n;

    ll aoki=0,takahashi=0;
    vector<ll> a(n),b(n);
    rep(i,n){
        cin >> a[i] >> b[i];
        aoki+=a[i];
    }
    vector<ll> c(n);
    rep(i,n) c[i]=2*a[i]+b[i];
    sort(all(c),greater<>());

    int ans=0;
    while(aoki>=takahashi){
        takahashi+=c[ans];
        ans++;
    }
    cout << ans << endl;
    
    return 0;
}