{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE LambdaCase #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.IntMap.Lazy            as IML
import qualified Data.Map.Strict               as M
import           Data.Char
import qualified Data.Array.IArray as A
import qualified Data.Array.Unboxed as UA
import Data.Bits
import Control.Monad.State.Strict
import qualified Data.Array.ST as STA
import qualified Data.Array.MArray as MA
import Control.Monad.ST



readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

solve :: Int -> [Int] -> [(Int, Int)] -> Int
solve n heights' abl = let 
    heights = IM.fromList $ zip [1..] heights'
    updator from to m = M.alter (\case 
            Nothing -> Just [to]
            Just l -> Just $ to : l
        ) from m
    paths = foldl' (\m (from, to) -> updator to from $ updator from to m) M.empty abl
    isGood i = case M.lookup i paths of
        Nothing -> True
        Just ps -> let
            myHeight = heights IM.! i
            in
            all ((myHeight > ) . (heights IM.!)) ps
    in 
    length $ filter isGood [1..n]


main :: IO ()
main = do
    (n, m) <- readTuple2
    heights <- readInts
    abl <- replicateM m readTuple2
    print $ solve n heights abl



