#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <ctime>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define make make_pair
#define fi first
#define se second
#define vi std::vector<int>;
#define DEBUG cout << "debug" << endl
#define CLOSE ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define CASE int Kase=0;cin>>Kase;for(int kase=1;kase<=Kase;kase++)
const int N = 1e5 + 5;
const int M = 1e6 + 5;
const int MOD = 1e9 + 7;
const int CM = 998244353;
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
template <typename T>
T MAX(T a, T b) { return a > b ? a : b; }
template <typename T>
T MIN(T a, T b) { return a > b ? b : a; }
template <typename T>
T GCD(T a, T b){ return b == 0 ? a : GCD(b, a % b); }
template <typename T>
T LCM(T a, T b){ return a / GCD(a, b) * b; }
template <typename T>
T ABS(T a) { return a > 0 ? a : -a; }
template <typename T>
T ADD(T a, T b, T MOD){ return (a + b) % MOD; }
template <typename T>
T DEL(T a, T b, T MOD) { return ((a - b) % MOD + MOD) % MOD; }
void solve(int kase){
    ll s, p;
    cin >> s >> p;
    for(ll i = 1; i * i <= p; i++) {
        if(p % i == 0) {
            ll x = i, y = p / i;
            if(x + y == s) {
                printf("Yes\n"); return;
            }
        }
    }
    printf("No\n");
}
const bool DUO = 0;
void TIME(){
    clock_t start, finish;
    double totaltime;
    start = clock();

    // 待测程序

    if(DUO) {CASE solve(kase);}
    else solve(1);
    // 待测程序

    finish = clock();
    totaltime = (double)(finish - start) / CLOCKS_PER_SEC;
    printf("\nTime:%lfms\n", totaltime * 1000);
}
int main(){
    #ifdef ONLINE_JUDGE
        // CLOSE;
        if(DUO) {CASE solve(kase);}
        else solve(1);
    #else
        // freopen("./data/a.txt", "r", stdin);
        // freopen("./data/a.txt", "w", stdout);
        TIME();
    #endif
    return 0;
}
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)

using ll = long long;
using namespace std;

const int INF = 1 << 30;

int main() {
    ll N;
    cin >> N;
    // vector<ll> A(N), B(N);
    vector<ll> C(N);
    ll aoki = 0;
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        aoki += a;
        ll total = 2 * a + b;
        C[i] = total;
    }
    sort(C.rbegin(), C.rend());

    ll counter = 0;
    ll total = 0;
    for (ll i = 0; i < N; i++) {
        counter++;
        total += C[i];
        // cout << "total: " << total << endl;

        if (total > aoki) break;
    }

    ll ans = counter;
    cout << ans << endl;
}