import qualified Data.Map as M
import Control.Monad
import Data.List

badObservatory a = do
 [b,c] <- map read . words <$> getLine :: IO[Int]
 return $ if (a M.! b) > (a M.! c) then [c] else if (a M.! b) < (a M.! c) then [b] else [b,c] 

main = do
 [n,m] <- map read . words <$> getLine :: IO[Int]
 hList <- M.fromList . (zip [1..n]) . words <$> getLine
 ans <- replicateM m $ badObservatory hList
 print $ (length hList) - (length (nub (concat ans)))