#pragma GCC optimize("O2")

#include <bits/stdc++.h>

namespace IN {
#define BUF_SIZE 1 << 17
static char buf[BUF_SIZE], *fs = buf, *ft = buf;
inline int nc() { return fs == ft && (ft = (fs = buf) + fread(buf, 1, BUF_SIZE, stdin), fs == ft) ? EOF : *fs++; }
template <typename T>
inline int rn(T &x) {
    x = 0;
    int f = 0;
    char ch = nc();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = 1;
        ch = nc();
        if (ch == EOF) return EOF;
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - 48;
        ch = nc();
    }
    x = f ? -x : x;
    return 0;
}
template <typename T>
inline int read(T &x) {
    return rn(x);
}
template <typename T, typename... Args>
inline int read(T &x, Args &...args) {
    rn(x);
    return read(args...);
}
#undef BUF_SIZE
}  // namespace IN

namespace OUT {
template <typename T>
inline void print(std::string, T x) {
    std::cout << x << std::endl;
}
template <typename T, typename... Args>
inline void print(std::string sep, T x, Args... args) {
    std::cout << x << sep;
    print(sep, args...);
}
}  // namespace OUT
using namespace IN;
using namespace OUT;
using namespace std;

#define INF 0x3f3f3f3f
#define LL long long
#define PLL pair<LL, LL>
#define PII pair<int, int>
#define MP make_pair
#define FI first
#define SE second
#define PB push_back
#define ALL(A) A.begin(), A.end()
#define BPQ(type, name) priority_queue<type> name
#define SPQ(type, name) priority_queue<type, vector<type>, greater<type>> name
#define REP(i, n) for (LL i = 0; i < (LL)n; ++i)
#define REP1(i, n) for (LL i = 1; i <= (LL)n; ++i)
#define REP_R(i, a, b) for (LL i = (LL)a; i < (LL)b; ++i)
#define REP_RR(i, a, b) for (LL i = (LL)a; i >= (LL)b; --i)
#define SETVAL(array, val) memset(array, val, sizeof(array))
// Debug
#define DISP(arr, n)                 \
    REP(i, n) cout << arr[i] << ' '; \
    cout << endl;
#define DISP1(arr, n)                 \
    REP1(i, n) cout << arr[i] << ' '; \
    cout << endl;
#define DISP_T(arr, n, m)                   \
    REP(i, n) {                             \
        REP(j, m) cout << arr[i][j] << ' '; \
        cout << endl;                       \
    }
#define DISP_T1(arr, n, m)                   \
    REP1(i, n) {                             \
        REP1(j, m) cout << arr[i][j] << ' '; \
        cout << endl;                        \
    }
#define SIZE 200010
LL t[SIZE];
int n;
int main() {
    read(n);
    LL tak = 0;
    REP(i, n) {
        LL a, b;
        read(a, b);
        t[i] = 2 * a + b;
        tak -= a;
    }
    sort(t, t + n, greater<LL>());
    int p = 0;
    while (tak <= 0) tak += t[p++];
    cout << p << endl;
    return 0;
}

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

#define stp(var, init, end) for (auto var = init; var < end; ++var)
#define ll long long

int main(void)
{
    int n, cou = 0;
    cin >> n;
    ll dif = 0, a, b;
    vector<ll> get(n);
    stp(i, 0, n)
    {
        cin >> a >> b;
        dif += a;
        get[i] = 2 * a + b;
    }
    sort(get.begin(), get.end(), [](ll a, ll b) { return a > b; });
    for (int x = 0; dif >= 0; ++x)
    {
        dif -= get[x];
        ++cou;
    }
    cout << cou;
    return 0;
}