#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int main(){
    int n,m; cin>>n>>m;
    pair<int,int> a[m]; rep(i,m) cin>>a[i].second>>a[i].first;
    sort(a,a+m);
    int left=-1,ans=0;
    rep(i,m){
        if(left<=a[i].second){
            left=a[i].first;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}
