h,w=map(int,input().split())
M=[]
for i in range(h):
    s=input()
    H=[]
    for j in range(w):
        H.append(0) if s[j]=="." else H.append(1)
    M.append(H)

def make2D(x,y):
    aM=[]
    for i in range(h):
        aH=[]
        for j in range(w):
            aH.append(0) if M[i][j]==0 else aH.append(-1)
        aM.append(aH)
    return aM

from collections import deque
ans=0
for i in range(h):
    for j in range(w):
        print(i,j)
        if M[i][j]==1:
            continue
        aM=make2D(h,w)
        q=deque()
        q.append([i,j])
        while q:
            now=q.popleft()
            for a,b in ([0,1],[1,0],[0,-1],[-1,0]):
                if 0<=now[0]+a<h and 0<=now[1]+b<w:
                    if aM[now[0]+a][now[1]+b]==0 and (now[0]+a!=i or now[1]+b!=j):
                        aM[now[0]+a][now[1]+b]=aM[now[0]][now[1]]+1
                        q.append([now[0]+a,now[1]+b])
            if len(q)==0:
                break
            print(aM)
        m=0
        for z in range(h):
            m=max(m,max(aM[z]))
        ans=max(ans,m)
print(ans)