let rotate h w a =
  Array.init w (fun i -> Array.init h (fun j -> a.(h-1-j).(i)))
let () =
  Scanf.scanf "%d %d" @@ fun h w ->
  let s = Array.init h (fun _ ->
    let s = Scanf.scanf " %s" (fun x -> x) in
    Array.init w (fun i -> s.[i]))
  in
  let rec calc n s t h w =
    if n <= 0 then t
    else begin
      for i = 0 to h-1 do
        let u = Array.make w 0 in
        if s.(i).(0) = '.' then u.(0) <- 1;
        for j = 1 to w-1 do
          if s.(i).(j) = '.' then
            u.(j) <- u.(j-1) + 1
        done;
        u |> Array.iteri (fun j v -> t.(i).(j) <- t.(i).(j) + v);
      done;
      calc (n-1) (rotate h w s) (rotate h w t) w h
    end
  in

  calc 4 s (Array.make_matrix h w (-3)) h w
  |> Array.fold_left (Array.fold_left max) 0
  |> Printf.printf "%d\n"

