#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <sstream>
#include <utility>

using namespace std;

typedef long long ll;
#define dbg(x) cerr << x << endl

struct Exam
{
    ll start, duration;
};

bool comp(Exam l, Exam r)
{
    if(l.start == r.start)
    {
        return l.duration < r.duration;
    }
    else
    {
        return l.start < r.start;
    }
}

int main()
{
    ll n;
    cin >> n;
    vector<Exam> exams(n);
    for(ll i = 0; i < n; i++)
    {
        cin >> exams[i].start >> exams[i].duration;
    }
    sort(exams.begin(), exams.end(), comp);
    ll total = exams[0].start;
    ll result = 0;
    for(ll i = 0; i < exams.size(); i++)
    {
        if(total >= exams[i].duration)
        {
            result++;
            total -= exams[i].duration;
        }
        if(i == exams.size() - 1)
        {
            break;
        }
        else
        {
            total += exams[i + 1].start - exams[i].start;
        }
    }
    dbg("Result = " << result);
    cout << result << endl;
    return 0;
}
