#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll N, M;
  cin >> N >> M;
  vector<pair<ll, ll>> P(M);
  REP(i, 0, M) cin >> P[i].second >> P[i].first;
  sort(P.begin(), P.end());

  ll ans = 0, t = 0;
  REP(i, 0, M) {
    if (t <= P[i].second) {
      ans++;
      t = P[i].first;
    }
  }
  cout << ans << endl;
}