#include <bits/stdc++.h>
#define filein(t) freopen(t, "r", stdin)
#define fileout(t) freopen(t, "w", stdout)
#define f first
#define s second
#define cs 137
#define ll long long
#define mp make_pair
#define N 300025
#define ln 1e16
#define oo 111539786
#define Pa pair < int, int >
#define Pi pair < int, Pa >

using namespace std;

Pa a[N];
priority_queue < int > que;
int n;

bool Check(int X)
{
    while(!que.empty())  que.pop();
    ll S = 0;
    for(int i=n; i>n-X; i--)
    {
        que.push(a[i].s);
        S += a[i].s;
    }
    if(S <= (ll)X * a[n-X+1].f)   return true;
    for(int i=n-X; i>=1; i--)
    {
        int Max = que.top();
        if(Max > a[i].s)
        {
            S = S - Max + a[i].s;
            que.pop();
            que.push(a[i].s);
        }
        if(S <= (ll)X * a[i].f) return true;
    }
    return false;
}

int main()
{
//    filein("MICROORGANISM.inp");    fileout("MICROORGANISM.out");
    cin >> n;
    for(int i=1; i<=n; i++)
        cin >> a[i].s >> a[i].f;
    sort(a+1, a+n+1);
    int L = 0;
    int R = n + 1;
    while(R - L > 1)
    {
        int X = (L + R) / 2;
        if(Check(X))    L = X;
        else
            R = X;
    }
    cout << L << endl;
}