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

int main()
{
  int64_t N, M, a, b, l = 0, ans = 0;
  cin >> N >> M;
  vector<pair<int64_t, int64_t>> vp(M);
  for (int i = 0; i < M; i++)
  {
    cin >> a >> b;
    vp.at(i) = make_pair(b, a);
  }
  sort(vp.begin(), vp.end());
  for (int i = 0; i < M; i++)
  {
    if (vp[i].second < l)
      continue;
    ans++;
    l = vp[i].first;
  }
  cout << ans << endl;
}