
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord
import Data.Maybe
import qualified Data.Set as S
import Data.Graph
import qualified Data.IntMap.Strict as IM 

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main :: IO ()
main = do
    [n,m] <- r'
    hs <- r n
    roads <- IM.fromListWith (++) <$> concat <$> replicateM m (do
        [a,b] <- r'
        return [(a,[b]),(b,[a])])
    -- let graph = buildG (1,n) (edges++edges2)
    -- print roads
    print $ length $ filter (good roads hs) [1..n]
    -- print 0

flipTup (a,b) = (b,a)

good :: IM.IntMap [Int] -> U.Vector Int -> Int -> Bool
good roads hs h = all (\k -> hs U.! (k-1) < hs U.! (h-1)) (fromMaybe [] (IM.lookup h roads))