import Control.Monad
import Data.IntMap.Strict ((!), fromList, IntMap)
import Data.IntSet hiding (map, fromList)
import qualified Data.IntSet as S
import Data.Function

main :: IO ()
main = do
  l1 <- getLine
  l2 <- getLine
  let [n, m] = map read $ words l1 :: [Int]
      h = fromList $ zip [1..] $ map read $ words l2 :: IntMap Int
  lm <- replicateM m getLine
  let ab = map (map read . words) lm :: [[Int]]

  print $ size $ proc h (S.fromList [1..n]) ab

proc h s [] = s
proc h s ([a, b]:ab) = proc h s' ab
  where
    c = (compare `on` (h !)) a b
    s' = case c of
      EQ -> delete a $ delete b s
      LT -> delete a s
      GT -> delete b s
