#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n,m; cin >> n >> m;
    pair<int, int> p[m+1];
    for (int i=0; i<m; i++) cin >> p[i].second >> p[i].first;
    sort(p, p+m);
    int ans=0, t=0;
    for (int i=0; i<m; i++){
        if (p[i].second>=t) t=p[i].first, ans++;
    }
    cout << ans << endl;
}
