import Data.Array

inputIntList :: IO [Int]
inputIntList = map read . words <$> getLine :: IO[Int]

isGood :: Array Int Int -> Array Int [Int] -> Int -> Bool
isGood hs paths idx = 0 == (length . filter (\x -> hs!idx <= hs!x)) (paths!idx)

main = do
    [n,m] <- inputIntList
    _hs <- inputIntList
    co <- getContents
    let hs = array (1,n) $ zip [1..] _hs
    let paths = accumArray (flip (:)) [] (1,n) $ foldl (\ p (x,y) -> ((x,y):(y,x):p)) [] $ map (\ [a,b] -> (a,b)) $ map (map read) $ map words $ lines co :: Array Int [Int]
    print $ length $ filter (isGood hs paths) [1..n]
    
