open Printf open Scanf
open Array

let print_array f a = Array.iter (fun v -> printf "%s " @@ f v) a; print_newline ()

let () = scanf " %d %s" @@ fun n s ->
  let a = init n (fun i -> s.[i]) in
  let b = ref @@ 0 in
  let w = ref @@ fold_left (fun u -> function
  | '.' -> u+1 | _ -> u) 0 a in
  init (n+1) (fun i ->
    let res =
      if i=0 then (
        !w
      ) else if i=n then (
        !b
      ) else (
        let ww = !b + (n - i - !w) in
        let wb = !b + !w in
        let bb = (i - !b) + !w in
        fold_left min max_int [|ww;wb;bb|]
      )
    in
    if i<n then (
      if a.(i) = '#' then b := !b + 1
      else w := !w - 1;
    );
    (* printf "%d :: %d,%d :: %d\n"
      i !b !w res; *)
    res
  )
  |> fold_left min max_int
  |> print_int






