import Control.Monad

replaceNth :: Int -> a -> [a] -> [a]
replaceNth i x xs = take i xs ++ [x] ++ drop (i + 1) xs

solve :: [Int] -> [Int] -> [[Int]] -> [Int]
solve _ maxHeights [] = maxHeights
solve hs maxHeights ([a, b]:links) =
  let heightA = hs !! a
      heightB = hs !! b
      maxHeightA = maxHeights !! a
      maxHeightB = maxHeights !! b
      newMaxHeightA = max heightB maxHeightA
      newMaxHeightB = max heightA maxHeightB
      newMaxHeights = replaceNth a newMaxHeightA $ replaceNth b newMaxHeightB maxHeights
   in solve hs newMaxHeights links


parseInts :: IO [Int]
parseInts = map (read :: String -> Int) . words <$> getLine

main :: IO ()
main = do
  [n, m] <- parseInts
  hs <- parseInts
  links <- replicateM m $ map pred <$> parseInts
  let maxHeights = take n $ repeat 0
  print $ length . filter (\(a, b) -> a > b) . zip hs $ solve hs maxHeights links
