open Array
let () =
  let rec make_list n = if n = 0 then [0] else n :: make_list (n-1) in
  let n,m = Scanf.scanf "%d %d\n" @@ fun a b -> a, b in
  let h = init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d in
  let arr = copy h in
  for i = 1 to m do
    Scanf.scanf "%d %d\n" @@ fun x y ->
    let a = x-1 in let b = y-1 in let x = max h.(a) h.(b) in
    arr.(a) <- max x arr.(a); arr.(b) <- max x arr.(b)
  done;
  print_int (List.fold_left (fun i v -> if h.(v) < arr.(v) then i+1 else i) 0 (make_list (n-1)))