#include<cstdio>#include<cstring>#include<algorithm>#include<set>#include<iostream>#include<vector>//#include<bits/stdc++.h>usingnamespace std;typedeflonglong ll;#define SIS std::ios::sync_with_stdio(false)#define space putchar(' ')#define enter putchar('\n')#define lson root<<1#define rson root<<1|1typedef pair<int,int> PII;constint mod=1e4+7;constint N=2e5+10;constint inf=0x7f7f7f7f;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}template<classT>voidread(T &x){char c;bool op =0;while(c =getchar(), c <'0'|| c >'9')if(c =='-')
op =1;
x = c -'0';while(c =getchar(), c >='0'&& c <='9')
x = x *10+ c -'0';if(op)
x =-x;}template<classT>voidwrite(T x){if(x <0)
x =-x,putchar('-');if(x >=10)write(x /10);putchar('0'+ x %10);}
PII a[N];intmain(){int n;scanf("%d",&n);for(int i=0;i<n;i++){scanf("%d%d",&a[i].second,&a[i].first);// a[i].second+=a[i].first-1;}sort(a,a+n);int ans=0,low=a[0].first;for(int i=1;i<n;i++){if(low<=a[i].second){
ans++; low=a[i].first;}}
cout<<ans+1<<endl;return0;}