#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  pair<int, int> P[M];
  for (int i = 0; i < M; i++) {
    cin >> P[i].second >> P[i].first;
  }
  sort(P, P + M);
  int ans = 0;
  int now = P[0].first;
  for (int i = 0; i < M; i++) {
    if (now <= P[i].second) {
      ans++;
      now = P[i].first;
    }
  }
  cout << ans + 1 << endl;
  return 0;
}
