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

const int INF = 1e9;

int main() {
  int n, m;
  cin>>n>>m;
  vector<pair<int, int> > p;
  p.reserve(m);
  for (int i=0; i<m; i++) {
    int a, b;
    cin>>a>>b;
    p.emplace_back(b, a);
  }
  sort(p.begin(), p.end());

  int ans = 0;
  int t = 0;
  for (auto x: p) {
    if (x.second >= t) {
      ++ans;
      t = x.first;
    }
  }
  cout<<ans<<endl;


}