let n, m = Scanf.scanf "%d %d\n" (fun n m -> n, m)

let h = Array.init n (fun _ -> Scanf.scanf " %d" (fun i -> i))

let h' = Array.make n 0

let rec f i =
  if i < m then (
    let a, b = Scanf.scanf "\n%d %d" (fun a b -> a - 1, b - 1) in
    if h'.(a) < h.(b) then h'.(a) <- h.(b);
    if h'.(b) < h.(a) then h'.(b) <- h.(a);
    f (i + 1)
  )

let rec g i ans =
  if i = n then ans
  else
    if h'.(i) < h.(i) then g (i + 1) (ans + 1)
    else g (i + 1) ans

let () =
  f 0;
  Printf.printf "%d\n" (g 0 0)
