#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 1e6+5;
const int mod = 1e9+7;
typedef pair<int, int> ii;
#define fi first
#define se second
#define read(_a, n) for(int i = 1; i <= n; i++) cin >> _a[i]
#define For(i, _a, _b) for(int i = _a; i <= _b; i++)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define File(_x,_y) if (fopen(_x, "r")) freopen(_x, "r", stdin)//,freopen(_y, "w", stdout)
#define file "main"
#define bit(x, i) ((x >> i) & 1)
#define bat(x, i) (x | (1 << i))

//a[i] = {cs, l, r}

int Rand(int l, int r)
{
    int ans = l + rand()%(r-l+1);
    return ans;
}

int n, m, dp[maxn], l[maxn], r[maxn];
int T[maxn*4], res;
int N = 4e6+5;

struct tp
{
    int cs;int l;int r;
} a[maxn];

void update(int p, int v)
{
    while(p <= N)
    {
        T[p] = max(v, T[p]);
        p += p&(-p);
    }
}

int get(int p)
{
    int res = 0;
    while(p > 0)
    {
        res = max(res, T[p]);
        p -= p&(-p);
    }
    return res;
}

bool cmp(tp a, tp b)
{
    return a.cs - a.l < b.cs - b.l;
}

int32_t main()
{
    fastIO;
    File(file ".inp", file ".out");
    cin >> n;
    For(i, 1, n)
    {
        cin >> l[i] >> r[i];
        a[i].cs = i;
        a[i].l = l[i];
        a[i].r = r[i];
    }
    sort(a+1, a+n+1, cmp);
    int j = 0;
    For(i, 1, n) dp[i] = 1;
    For(i, 1, n)
    {
        while(j+1 < a[i].cs - a[i].l)
        {
            j++;
           update(j + r[j], dp[j]);
        }
        dp[a[i].cs] = max(dp[a[i].cs], get(a[i].cs - 1) + 1);
        res = max(dp[a[i].cs], res);
    }
    cout << res;
}
