import sys
import copy
sys.setrecursionlimit(10**7)

h,w = map(int,input().split())
s = [list(input()) for i in range(h)]
count = 0

def dfs(x,y,gx,gy,c):
    global count
    global ans
    if not(0 <= x < h) or not(0 <= y < w) or c[x][y] == "#":
        return
    else:
        count += 1
    if x == gx and y == gy:
        ans.append(count)
        #print(count)
        return count
    c[x][y] = "#"
    dfs(x+1,y, gx, gy,c)
    dfs(x-1,y, gx, gy,c)
    dfs(x,y+1, gx, gy,c)
    dfs(x,y-1, gx, gy,c)

sx, sy = 0, 0
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            sx, sy = i, j
            break
        
ans = []

for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            gx, gy = i, j
            c = copy.deepcopy(s)
            (dfs(sx, sy, gx, gy, c))
            count = 0

print(max(ans)-1)