let () = Scanf.scanf "%d %d\n" @@ fun h w ->
  let ss = Array.init h @@ fun _ -> Scanf.scanf "%s\n" @@ fun s -> s in
  let lacc = Array.make_matrix h w 0 in
  let racc = Array.make_matrix h w 0 in
  let uacc = Array.make_matrix h w 0 in
  let dacc = Array.make_matrix h w 0 in
  for i = 0 to h - 1 do
    for j = 1 to w - 1 do
      if ss.(i).[j - 1] = '.' then
        lacc.(i).(j) <- lacc.(i).(j - 1) + 1
    done
  done;
  for i = h - 1 downto 0 do
    for j = w - 2 downto 0 do
      if ss.(i).[j + 1] = '.' then
        racc.(i).(j) <- racc.(i).(j + 1) + 1
    done
  done;
  for i = 1 to h - 1 do
    for j = 0 to w - 1 do
      if ss.(i - 1).[j] = '.' then
        uacc.(i).(j) <- uacc.(i - 1).(j) + 1
    done
  done;
  for i = h - 2 downto 0 do
    for j = w - 1 downto 0 do
      if ss.(i + 1).[j] = '.' then
        dacc.(i).(j) <- dacc.(i + 1).(j) + 1
    done
  done;
  Printf.printf "%d\n" @@
  Array.fold_left (Array.fold_left max) min_int @@
  Array.init h @@ fun i ->
    Array.init w @@ fun j ->
      if ss.(i).[j] = '#'
      then 0
      else 1 + lacc.(i).(j) + racc.(i).(j) + uacc.(i).(j) + dacc.(i).(j)
