#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

typedef long long ll;
const int maxn=2e5+5;
ll p[maxn];
bool cmp(ll a,ll b){
    return a>b;
}

int main(){
    int n;
    cin>>n;
    ll sum=0;
    for(int i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        sum+=a;
        p[i]=2*a+b;
    }
    sort(p,p+n,cmp);
    int ans=0;
    ll sumb=0;
    for(int i=0;i<n;i++){
        sumb+=p[i];
        ans++;
        if(sum<sumb)
            break;
    }
    cout<<ans<<endl;
    return 0;
}
#include <bits/stdc++.h>
#define repr(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define reprrev(i, a, b) for (int i = b - 1; i >= a; i--) // [a, b)
#define reprev(i, n) reprrev(i, 0, n)
#define _GLIBCXX_DEBUG

using ll = long long;
using ull = unsigned long long;
template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
const ll mod = 1e9 + 7;
const ll INF = 1e18;
void chmod(ll &M)
{
  if (M >= mod)
    M %= mod;
  else if (M < 0)
  {
    M += (abs(M) / mod + 1) * mod;
    M %= mod;
  }
}
ll modpow(ll x, ll n)
{
  if (n == 0)
    return 1;
  ll res = modpow(x, n / 2);
  if (n % 2 == 0)
    return res * res % mod;
  else
    return res * res % mod * x % mod;
}
   
int getl(int i, int N) { return i == 0 ? N - 1 : i - 1; };
int getr(int i, int N) { return i == N - 1 ? 0 : i + 1; };
long long GCD(long long a, long long b)
{
  if (b == 0)
    return a;
  else
    return GCD(b, a % b);
}
using namespace std;

int main() {
  int N; cin >> N;
  ll A = 0;
  vector<pair<ll, ll>> P(N);
  vector<ll> sum(N);
  rep(i, N) {
   cin >> P[i].first >> P[i].second;
   A += P[i].first;
   ll s = 2*P[i].first + P[i].second;
   sum[i] = s;
}

sort(sum.rbegin(), sum.rend());

vector<ll> S(N+1, 0);
rep(i, N) {
  S[i+1] = S[i] + sum[i];
}

auto it = lower_bound(S.begin(), S.end(), A+1);

ll ans = it - S.begin();
cout << ans << endl;
}