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

def route(l):
  routeout = []
  if l[0] > 0:
    if sc[l[1]][l[0]-1] == '.':
      routeout.append([l[0]-1, l[1]])
  if l[0] < w-1:
    if sc[l[1]][l[0]+1] == '.':
      routeout.append([l[0]+1, l[1]])
  if l[1] > 0:
    if sc[l[1]-1][l[0]] == '.':
      routeout.append([l[0], l[1]-1])
  if l[1] < h-1:
    if sc[l[1]+1][l[0]] == '.':
      routeout.append([l[0], l[1]+1])
  return routeout

def f(linl, out):
  nextxy = []
  for l in linl:
    nextxy += route(l)
    for ll in route(l):
      sc[ll[1]][ll[0]] = '#'
  if len(nextxy)>0:
    return f(nextxy, out+1)
  else:
    return out
  
r = set()
for i in range(h):
  for j in range(w):
    if s[i][j] == '.':
      sc = [[l for l in ll] for ll in s]
      sc[i][j] = '#'
      r.add(f([[j, i]], 0))
print(r)
print(max(r))