;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(declaim (inline read-line-into))
(defun read-line-into (buffer-string &key (in *standard-input*) (terminate-char #\Space))
  "Receives ascii inputs and returns the string and the end position. Note that
the returned string will be reused.

This function calls READ-BYTE to read characters though it calls READ-CHAR
instead on SLIME because SLIME's IO is not bivalent."
  (declare (inline read-byte)) ; declaring (sb-kernel:ansi-stream in) will be faster
  (loop for c of-type base-char =
           #-swank (code-char (read-byte in nil #.(char-code #\Newline)))
           #+swank (read-char in nil #\Newline)
        for idx from 0
        until (char= c #\Newline)
        do (setf (char buffer-string idx) c)
        finally (when (< idx (length buffer-string))
                  (setf (char buffer-string idx) terminate-char))
                (return (values buffer-string idx))))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (let* ((h (read))
         (w (read))
         (plan (make-array (list h w) :element-type 'bit :initial-element 0))
         (h-dp (make-array (list h w) :element-type 'uint32 :initial-element 0))
         (v-dp (make-array (list h w) :element-type 'uint32 :initial-element 0))
         (line (make-string w :element-type 'base-char)))
    (dotimes (i h)
      (read-line-into line)
      (dotimes (j w)
        (when (char= #\# (aref line j))
          (setf (aref plan i j) 1))))
    (loop for i below h
          do (let ((base -1))
               (loop for j below w
                     do (when (= 1 (aref plan i j))
                          (loop for pos from (- j 1) above base
                                do (setf (aref h-dp i pos) (- j base 1)))
                          (setf base j))
                     finally (loop for pos from (- j 1) above base
                                   do (setf (aref h-dp i pos) (- j base 1))))))
    (loop for j below w
          do (let ((base -1))
               (loop for i below h
                     do (when (= 1 (aref plan i j))
                          (loop for pos from (- i 1) above base
                                do (setf (aref v-dp pos j) (- i base 1)))
                          (setf base i))
                     finally (loop for pos from (- i 1) above base
                                   do (setf (aref v-dp pos j) (- i base 1))))))
    (let ((res 0))
      (dotimes (i h)
        (dotimes (j w)
          (setf res (max res (+ (aref h-dp i j) (aref v-dp i j) -1)))))
      (println res))))

#-swank(main)


Measured memory_bytes: 55784