#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
  int n, m,a,b,cut = 0, ans = 0;;
  cin >> n >> m;
  vector<pair<int, int>> v(m);
  rep(i, m) cin >> a >> b, v[i] = {--b, --a};
  sort(v.begin(), v.end());
  for (auto x : v) if (x.second >= cut) ans++, cut = x.first;
  cout << ans << endl;
}
