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

solve :: M.Map Int Int -> S.Set Int -> [[Int]] -> Int
solve hMap hSet routeList
 | null routeList = S.size hSet
 | otherwise = solve hMap deletedHSet (tail routeList)
   where leftObservatory = (head routeList) !! 0
         rightObservatory = (head routeList) !! 1
         leftHeight  = hMap M.! leftObservatory
         rightHeight = hMap M.! rightObservatory
         deletedHSet = if leftHeight > rightHeight      then S.delete rightObservatory hSet
                       else if leftHeight < rightHeight then S.delete leftObservatory hSet
                       else hSet -- S.delete rightObservatory$ S.delete leftObservatory hSet    
main = do
 [n,m] <- map read . words <$> getLine :: IO[Int]
 hList <- map read . words <$> getLine :: IO[Int]
 let hMap = M.fromList $ zip [1..] $ hList
 let hSet = S.fromList $ hList
 routeList <- replicateM m (map read . words <$> getLine) :: IO[[Int]]
 print $ solve hMap hSet routeList