let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let as_ = Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  Array.to_list as_
  |> (fun (h :: t) ->
    List.fold_left (fun (acc, a, dir) a' ->
      if dir = 0 || compare a a' = dir then (acc, a', compare a a')
      else if compare a a' = 0 then (acc, a', dir)
      else (1 + acc, a', 0)) (1, h, 0) t)
  |> (fun (acc, _, _) -> acc)
  |> Printf.printf "%d\n"
