using System; using System.Collections.Generic; using static System.Console; using System.Linq; class yuki301 { static int[] NList => Console.ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NMap(int n) => Enumerable.Repeat(0, n).Select(_ => NList).ToArray(); static void Main() { var c = NList; var (n, m) = (c[0], c[1]); var map = NMap(m); Array.Sort(map, (a, b) => a[1].CompareTo(b[1])); var pos = 0; var res = 0; while (pos < m) { ++res; var right = map[pos][1]; while (pos < m && map[pos][0] <= right) ++pos; } WriteLine(n - res); } }