#include <iostream>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;

int main() {
	int N, M;
	cin >> N >> M;

	P lis[100000];

	for (int i = 0; i < M; i++) {
		int a, b; cin >> a >> b;
		lis[i] = P(b, a);
	}

	sort(lis, lis+M);

	int ans = 0, now = -1;

	for (int i = 0; i < M; i++) {
		if (lis[i].second >= now) {
			now = lis[i].first;
			ans++;
		}
	}

	cout << ans << endl;
}