
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define int long long
const int MAXN=10100;

struct str
{
    ll t,  d;
}arr[MAXN];

bool operator< (str a, str b)
{
    return a.d<b.d;
}

bool used[MAXN];

main()
{
    int n;
    cin >> n;
    for(int i = 0; i<n; i++)
    {
        ll x, y;
        cin >>arr[i].d >> arr[i].t;
    }
    sort(arr, arr+n);

    ll t =0, last = 0;
    ll ans = 0;
    for(int i = 0; i<n; i++)
    {
        t+=arr[i].d-last;
        last = arr[i].d;
        if(t>=arr[i].t){
            ans++;
            used[i]=true;
            t-=arr[i].t;
        }
        else
        {
            ll pos = -1;
            for(int j = 0; j<i; j++)
                if(pos==-1 || (used[j] && arr[j].t>arr[pos].t))
                pos=j;
            if(arr[pos].t>arr[i].t){
                t+=arr[pos].t;
                t-=arr[i].t;
                used[pos]=0;
                used[i]=1;
            }
        }
    }
    cout << ans << '\n';

}
