import java.util.Scanner

fun main(args: Array<String>) {
	val scanner = Scanner(System.`in`)
	val n = scanner.nextInt()
	val m = scanner.nextInt()
	val arr = Array(m){Pair(scanner.nextInt(), scanner.nextInt())}
	arr.sortBy { it.second }
	var ans = 0
	var last = 0
	arr.forEach {
		if (last<it.first){
			ans++
			last = it.second-1
		}
	}
	println(ans)
}