#include <iostream>
#include <map>
using namespace std;

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

  multimap<int,int> m;
  int a, b;
  for(int i = 0; i < M; ++i){
    cin >> a >> b;
    m.emplace(make_pair(b, a));
  }

  int x = 0;
  int ans = 0;
  for(const auto& e : m){
    if(x <= e.second){
      x = e.first;
      ++ans;
    }
  }

  cout << ans << endl;
}