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 bridge = new Array(n-1).fill(false);
  bridge[a_b[0][1]-2] = true;
  ans = 1; 
  for (var i=0; i<m; i++) {
    var flag = true;
    for (var j = a_b[i][0]-1; j < n-1; j++) {
      if (bridge[j]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      bridge[a_b[i][1]-2] = true;
      ans++;
    }
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));