import Control.Monad (replicateM)
import Data.List (sort, sortBy)
import Data.Maybe (fromJust)
import qualified Data.ByteString.Char8 as B

main = do
  [n, m] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine 
  ns <- replicateM m ((\[a,b] -> (a,b)) . 
          map (fst . fromJust . B.readInt) . B.words <$> B.getLine)
  print $ solve 0 . sortBy (\(_,a) (_,b) -> compare a b) $ ns

solve :: Int -> [(Int, Int)] -> Int 
solve count [] = count 
solve count (t:ts) = solve (count + 1) (filter (\(a,_) -> a > (snd t)) ts)