let rec fold_for a b v f = if a >= b then v else fold_for (a+1) b (f a v) f
let () =
  Scanf.scanf "%d %d" @@ fun h w ->
  let s = Array.init h (fun _ -> Scanf.scanf " %s" (fun x -> x)) in
  let f x y = s.(x).[y] in

  let t = Array.make_matrix h w (-3) in
  let g x y v = t.(x).(y) <- t.(x).(y) + v in

  let rec loop n f g h w =
    if n <= 0 then ()
    else begin
      for i = 0 to h-1 do
        ignore @@ fold_for 1 w (if f i 0 = '.' then 1 else 0) @@ fun j v ->
        let v' = if f i j = '.' then v+1 else 0 in
        g i j v'; v'
      done;
      loop (n-1) (fun x y -> f (h-1-y) x) (fun x y -> g (h-1-y) x) w h
    end
  in
  loop 4 f g h w;

  Array.fold_left (Array.fold_left max) 0 t
  |> Printf.printf "%d\n"

