{-# LANGUAGE BangPatterns, MagicHash #-}
import Control.Monad
import Control.Applicative
import Data.List
import Data.Maybe
import Data.Bits
import qualified Data.IntMap.Strict as M
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
import Data.Vector.Unboxed ((!))
import Data.Tuple
import Data.Ord (Down(..))
import Data.Coerce
                                 
query :: Int -> [(Int,Int)] -> Int
query n = snd . foldl' loop (Nothing,0) . sortOn snd
  where
    loop (Nothing,i) (_,b) = (Just b, i+1)
    loop (Just x, i) (a,b) | a < x = (Just x, i)
                           | otherwise = (Just b, i+1)
     
main :: IO ()
main = do
  [n,m] <- map read . words <$> getLine
  ls <- replicateM m $ (\(x:y:_)->(x,y)) . map read . words  <$> getLine
  putStrLn $ show $ query n ls