#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> V(M);
  for (int i = 0, a, b; cin >> a >> b; i++) V.at(i) = {b, a};
  sort(V.begin(), V.end());
  int cut = 0, ans = 0;
  for (auto [a, b] : V) if (b > cut) ans++, cut = --a;
  cout << ans << "\n";
}