#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int N, M; 
	cin >> N >> M; 
	pair<int, int> A[100010]; 
	for(int i = 0; i < M; i++){
		int a, b; 
		cin >> a >> b; 
		A[i].first = b, A[i].second = a; 
	}
	sort(A, A+M);
	int count = 0, R = 0; 
	for(int i = 0; i < M; i++){
		if(A[i].second >= R){
			count ++; 
			R = A[i].first; 
		}
	}
	cout << count << endl; 
}