import Control.Monad
import qualified Data.Set as Set

replaceNth :: Int -> a -> [a] -> [a]
replaceNth i x xs = take i xs ++ [x] ++ drop (i + 1) xs

solve :: [Int] -> Set.Set Int -> [[Int]] -> Set.Set Int
solve _ badTwrs [] = badTwrs
solve hs badTwrs ([a, b]:links) =
  let heightA = hs !! (a - 1)
      heightB = hs !! (b - 1)
      newBadTwrs = case heightA `compare` heightB of
                     GT -> Set.delete b badTwrs
                     LT -> Set.delete a badTwrs
                     EQ -> Set.delete a $ Set.delete b badTwrs
   in solve hs newBadTwrs links


parseInts :: IO [Int]
parseInts = map (read :: String -> Int) . words <$> getLine

main :: IO ()
main = do
  [n, m] <- parseInts
  hs <- parseInts
  links <- replicateM m parseInts
  let badTwrs = Set.fromList [1..n]
  print $ Set.size $ solve hs badTwrs links
