import Control.Monad
import Data.List

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

solve :: [Int] -> [Bool] -> [[Int]] -> [Bool]
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 -> replaceNth (b - 1) False badTwrs
                     LT -> replaceNth (a - 1) False badTwrs
                     EQ -> replaceNth (a - 1) False $ replaceNth (b - 1) False 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 = take n $ repeat True
  print $ length . filter (== True) $ solve hs badTwrs links
