open Printf open Scanf
open Array

let () = scanf " %d %s" @@ fun n s ->
  let black = make n 0 in
  let white = make n 0 in
  for i=0 to n-1 do
    if i=0 && s.[i]='#' then (
      black.(i) <- 1;
    ) else if s.[i] = '#' then (
      black.(i) <- black.(i-1) + 1;
    ) else (
      black.(i) <- 0;
    )
  done;
  for i=n-1 downto 0 do
    if i=n-1 && s.[i] <> '#' then (
      white.(i) <- 1;
    ) else if s.[i] <> '#' then (
      white.(i) <- white.(i+1) + 1;
    ) else (
      white.(i) <- 0;
    )
  done;
  let res = ref 0 in
  let f = ref false in
  let a = init n (fun i -> s.[i]) in
  for i=0 to n-2 do
    if a.(i) = '#' && a.(i+1) = '.' then (
      f := false;
      let l,r = black.(i), white.(i+1) in
      if l<r then (
        res := !res + l;
      ) else (
        res := !res + r;
        f := true;
      )
    ) else if a.(i) = '.' && !f then (
      a.(i) <- '#';
    )
  done;
  print_int @@ !res
