#include <bits/stdc++.h>
using namespace std;
using lint = long long;
typedef pair<int, int> P;
const int INF = 1e9;

int main(){
	int N, M; cin >> N >> M;
	vector<P> vec(M);
	for(int i = 0; i < M; i++) cin >> vec[i].second >> vec[i].first;
	sort(vec.begin(), vec.end());
	int start = 0, ans = 0;
	for(int i = 0; i< M; i++){
		if(start <= vec[i].second) ans++, start = vec[i].first;
	}
	cout << ans << endl;
}