import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Vector.Unboxed as VU
import Data.List ((\\))
import Data.Function (on)

main :: IO ()
main = do
  [n, m] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  hs <- VU.fromList . map unsafeTextToInt . T.words <$> T.getLine :: IO (VU.Vector Int)
  let
    loser :: (Int, Int) -> [Int]
    loser (i, j) = case (compare `on` (hs VU.!)) i j of
                     LT -> [i]
                     GT -> [j]
                     _  -> [i, j]
  abs <- sequence . replicate m $ unsafeListToPair . map (pred . unsafeTextToInt) . T.words <$> T.getLine :: IO [(Int, Int)]
  let
    losers = VU.accum (flip const) (VU.replicate n True) . map (flip (,) False) . concatMap loser $ abs :: VU.Vector Bool
  print . VU.length . VU.filter id $ losers

unsafeListToPair :: [Int] -> (Int, Int)
unsafeListToPair [x, y] = (x, y)

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
