function Main(s) {
  var s = s.split("\n").map(e => e.split(" ").map(e => e*1));
  n = s[0][0], m = s[0][1];
  a_b = s.slice(1, m+1).sort((a, b) => a[1]-b[1]);
  var end = a_b[0][1];
  var ans = 1;
  for (var i = 0; i < m; i++) {
    if (end <= a_b[i][0]) {
      ans++;
      for (var j = i; j < m; j++) {
        if (end < a_b[j][1]) {
          end = a_b[j][1];
          break;
        }
      }
    }
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));