#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using V = vector<ll>;

int main()
{
    ll n;
    cin >> n;
    vector<P> town(n);
    V taka(n);
    ll takahashi = 0;
    ll aoki = 0;
    for (int i = 0; i < n; i++)
        cin >> town[i].first >> town[i].second;
    for (int i = 0; i < n; i++)
    {
        aoki += town[i].first;
        taka[i] = town[i].first * 2 + town[i].second;
    }
    sort(taka.begin(), taka.end(), greater<>());
    for (int i = 0; i < n; i++)
    {
        takahashi += taka[i];
        if (takahashi > aoki)
        {
            cout << i + 1 << endl;
            return 0;
        }
    }
}

#define wiwihorz
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma loop-opt(on)

#define rep(i, a, b) for(int i = a; i <= b; i++)
#define rrep(i, a, b) for(int i = b; i >= a; i --)
#define all(x) x.begin(), x.end()
#define ceil(a, b) ((a + b - 1) / (b))

#define MAXN 1000005
#define MOD 1000000007
#define INF 1000000000000000000
#define eps (1e-9)

#define int long long int
#define lld long double
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())

using namespace std;
#ifdef wiwihorz
#define print(a...) out("[" + string(#a) +"] = ", a)
void vprint(auto L, auto R) {while(L < R) cerr << *L << " \n"[next(L) == R], ++L;}
void out() {cerr << endl;}
template<class T1, class ... T2> void out(T1 a, T2 ... e) {cerr << a <<" ", out(e...);}
#else 
#define print(...) 0
#define vprint(...) 0
#endif
int n, s, A, B;
vector<int> a;
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n, s = 0;
	rep(i, 1, n) {
		cin >> A >> B;
		s += A;
		a.push_back(2 * A + B);
	}

		sort(all(a)), reverse(all(a));
//		vprint(all(a)), print(s);
		int ans = 0;
		rep(i, 0, n - 1) {
			s -= a[i];
			if(s < 0) {
				ans = i + 1;
				break;
			}
		}
		cout << ans << "\n";

	return 0;
}  