let () =
  Scanf.scanf "%d" @@ fun n ->
  Array.init n (fun i -> Scanf.scanf " %d" (fun x -> x))
  |> Array.fold_left (fun (s, p) v -> if p = v then (s+1, -1) else (s, v)) (0, -2)
  |> fst |> Printf.printf "%d\n"