import Data.Array

main = do
  li <- getLine
  let [n,m] = map read $ words li
  li <- getLine
  let hs = map read $ words li
  co <- getContents
  let abs = map (l2p . map read . words) $ lines co
  let ans = compute n m hs abs
  print ans

l2p [a,b] = (a,b)

compute :: Int -> Int -> [Int] -> [(Int,Int)] -> Int
compute n m hs abs = length [ () | b <- elems ba, b ]
  where
    ha = listArray (1,n) hs
    ba = accumArray (&&) True (1,n) [ (x, ha ! x > ha ! y) | (a,b) <- abs, (x,y) <- [(a,b),(b,a)] ]
