#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
#include <cstring>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<ll,ll> Q;

const int MAX_N = 3 * 100000;

class SegmentTree{
public:
    SegmentTree(){}
    SegmentTree(int n)
    {init(n);}
    void init(int n){
        size = 1;
        while(size < n){
            size *= 2;
        }

        memset(data, 0, sizeof(data));
    }
    void add(int index, int v){
        index += size;
        data[index][0] = v;
        data[index][1] = index - size;
        
        while(index > 0){
            int parent = (index - 1) / 2,
                cl = parent * 2 + 1, cr = parent * 2 + 2;

            if(data[cl][0] > data[cr][0]){
                data[parent][0] = data[cl][0];
                data[parent][1] = data[cl][1];
            }else{
                data[parent][0] = data[cr][0];
                data[parent][1] = data[cr][1];
            }

            index = parent;
        }
    }
    Q root(){
        return mp(data[0][0], data[0][1]);
    }
    ll query(int a, int b){
        return _query(a, b, 0, 0, size);
    }
private:
    ll _query(int a, int b, int v, int l, int r){
        if(b <= l || r <= a){return 0;}
        if(a <= l && r <= b){return data[v][0];}

        return std::max(_query(a, b, 2*v+1, l, (l+r)/2), _query(a, b, 2*v+2, (l+r)/2, r));
    }

    ll data[MAX_N*4][2];
    int size;
};

int N;
std::vector<P> B;
SegmentTree st;

bool compareP(const P& lp, const P& rp){
    if(lp.second == rp.second){
        return lp.first < rp.first;
    }
    return lp.second > rp.second;
}


bool can(int n){
    st.init(n);

    ll foo = 0ll;
    REP(i, n-1){
        foo += B[i].first;
        st.add(i, B[i].first);
    }

    FOR(i, n-1, N){
        if(i == n-1){
            foo += B[i].first;
            st.add(i, B[i].first);
        }else{
            Q root = st.root();
            
            if(root.first > B[i].first){
                foo = foo - root.first + B[i].first;
                st.add(root.second, B[i].first);
            }
        }

        if(foo <= (ll)n*B[i].second){return true;}
    }
    return false;
}

int main(){
    std::cin >> N;

    B.resize(N);
    REP(i, N){
        std::cin >> B[i].first >> B[i].second;
    }

    std::sort(B.begin(), B.end(), compareP);

    int lb = 0, ub = N+1;
    while(ub-lb > 1){
        int mid = (ub+lb) / 2;
        if(can(mid)){
            lb = mid;
        }else{
            ub = mid;
        }

        //printf("[%d, %d)\n", lb, ub);
    }

    std::cout << lb << std::endl;
}