import Control.Applicative
import Control.Monad
import Data.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
import Data.List
import Data.Char (isSpace)
import Data.Vector (Vector, (!), (//))
import qualified Data.Vector as V
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS

main :: IO ()
main = do
  [n, m] <- g
  solve n <$> f <*> replicateM m g >>= print
  where
    f = readiv B.readInt <$> B.getLine
    g = map read <$> words <$> getLine

solve :: Int -> Vector Int -> [[Int]] -> Int
solve n vh = (n -) . IS.size . foldl f IS.empty
  where
    f st [a, b] = case compare (vh ! (a - 1)) (vh ! (b - 1)) of
      GT -> IS.insert b st
      LT -> IS.insert a st
      EQ -> IS.insert a (IS.insert b st)

readiv :: Integral a =>  (ByteString -> Maybe (a, ByteString)) -> ByteString -> Vector a
readiv f = V.unfoldr $ \s -> do
  (n, s') <- f s
  return (n, B.dropWhile isSpace s')
