{-# LANGUAGE OverloadedStrings #-}
import Control.Monad
import Data.Char
import Data.Maybe
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

main :: IO ()
main = do
  (n,m) <- getHogeVab readIntV
  h <- V.thaw =<< V.unfoldrN n readIntV <$> B.getLine
  -- h <- VM.new n
  ma <- VM.replicate (max m n) 0

  -- forM_ [0..(n-1)] $ \i -> do
  --   getInt >>= VM.write h i

  forM_ [0..(m-1)] $ \_ -> do
    (a,b) <- getHogeVab readIntV
    max <$> (VM.read ma (a-1)) <*> (VM.read h (b-1)) >>= VM.write ma (a-1)
    max <$> (VM.read ma (b-1)) <*> (VM.read h (a-1)) >>= VM.write ma (b-1)

  forM_ [0..(n-1)] $ \i -> do
    ma' <- VM.read ma i
    h'  <- VM.read h i
    if ma' < h'
      then VM.write ma i 1
      else VM.write ma i 0

  print =<< return . V.sum =<< V.freeze ma

----------------------------------------------------------------------

tupleToBString (m,n) = B.concat [m,n]

tuplify2 (x:y:_) = (x,y)
tuplify2 _ = undefined

readInt = fst . fromJust . B.readInt
readIntTuple = tuplify2 . map readInt . B.words
readIntList = map readInt . B.words

readIntV = B.readInt . B.dropWhile isSpace
getIntV n = getHogeV readIntV n
getHogeV f n = V.unfoldrN n f <$> B.getLine
getHogeVab f = (\vec -> (vec V.! 0, vec V.! 1)) <$> getHogeV f 2
getHogeVabs f n = V.replicateM n <$> getHogeVab f

getInt = fmap readInt B.getLine
getIntList = fmap readIntList B.getLine
getIntNList n = fmap (map readIntList) $ replicateM (fromIntegral n) B.getLine
getIntNtuple n = replicateM n $ tuplify2 . B.words <$> B.getLine
getIntVec n = V.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine

toDouble x = fromInteger x :: Double
