(require 'sb-queue)

(defun get-shortest (h w map start-x start-y)
  (let ((q (sb-queue:make-queue :initial-contents (list (list start-x start-y 0))))
        (looked (make-array (list h w) :element-type 'fixnum)))
    (loop until (sb-queue:queue-empty-p q)
          for (x y score) = (sb-queue:dequeue q)
          for next-score = (1+ score)
          maximize (prog1
                       score
                     (setf (aref looked y x) 1)
                     ;; left
                     (when (and (<= 0 (1- x))
                                (/= -1 (aref map y (1- x)))
                                (= 0 (aref looked y (1- x))))
                       (sb-queue:enqueue (list (1- x) y next-score) q))
                     ;; up
                     (when (and (<= 0 (1- y))
                                (zerop (aref map (1- y) x))
                                (= 0 (aref looked (1- y) x)))
                       (sb-queue:enqueue (list x (1- y) next-score) q))
                     ;; right
                     (when (and (< (1+ x) w)
                                (zerop (aref map y (1+ x)))
                                (= 0 (aref looked y (1+ x))))
                       (sb-queue:enqueue (list (1+ x) y next-score) q))
                     ;; down
                     (when (and (< (1+ y) h)
                                (zerop (aref map (1+ y) x))
                                (= 0 (aref looked (1+ y) x)))
                       (sb-queue:enqueue (list x (1+ y) next-score) q))))))

(defun solve (h w map)
  (loop for y from 0 below h
        maximize (loop for x from 0 below w
                       if (/= -1 (aref map y x))
                       maximize (get-shortest h w map x y))))

#-swank
(let* ((h (read))
       (w (read))
       (map (make-array (list h w) :element-type 'fixnum)))
  (loop for y from 0 below h
        do (loop for x from 0 below w
                 for byte = (read-byte *standard-input*)
                 do (setf (aref map y x)
                          (if (= byte #.(char-code #\.))
                              0
                              -1)))
        do (read-byte *standard-input*))
  (format t "~A~%" (solve h w map)))
