
import Control.Monad
import Data.List
import Data.Maybe
import qualified Data.Map as M
import qualified Data.Set as S

solve hs [] re = re
solve hs ([ai,bi]:abss) re
    | a < b = solve hs abss (S.delete ai re)
    | a > b = solve hs abss (S.delete bi re)
    | otherwise = solve hs abss (S.delete ai $ S.delete bi re)
        where
            a = hs M.! ai
            b = hs M.! bi

main = do
    [n,m] <- map read . words <$> getLine :: IO [Int]
    hs <- map read . words <$> getLine :: IO [Int]
    abss <- replicateM m (map read . words <$> getLine) :: IO [[Int]]
    print $ S.size $ solve (M.fromList $ zip [1..] $ hs) abss (S.fromList $ [1..n])
