#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, m; cin >> n >> m;
	vector<pair<int,int>> v;
	for(int i=0;i<m;i++){
		int a, b; cin >> a >> b;
		v.push_back({b,a});
	}
	sort(v.begin(), v.end());
	int ans = 0;
	int r = -1;
	for(int i=0;i<m;i++){
		if(v[i].second<r){
			continue;
		}else{
			ans++;
			r = v[i].first;
		}
	}
	cout << ans << endl;
	return 0;
}