"""
ぱっと見深さ優先探索で解ける
通った道を#にする
"""
import sys
sys.setrecursionlimit(10 ** 7)


H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

print(S)

nx = [1, 0, -1, 0]
ny = [0, -1, 0, 1]

ans = 0
def dfs(h, w, count):
    if not(0 <= h < H) or not(0 <= w < W) or S[w][h] == "#":
        return max(ans, count)
    else:
        count += 1
        for i in range(4):
            dfs(h + ny[i], w + nx[i], count)
        

ans = 0
for h in range(H):
    for w in range(W):
        ans = dfs(h, w, 0)

print(ans)