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
        let u = Array.make w 0 in
        if f i 0 = '.' then u.(0) <- 1;
        for j = 1 to w-1 do
          if f i j = '.' then
            u.(j) <- u.(j-1) + 1
        done;
        u |> Array.iteri (g i);
      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"