H,W=map(int,input().split())
S=[[0 for i in range(W)]for j in range(H)]
def mawari(r,c):
  no=W*(r-1)+c
  an={}
  an=set(an)
  if no%W==0:
    an=an|{no-1}
  elif no%W==1:
    an=an|{no+1}
  else:
    an=an|{no+1,no-1}
  if no<=W:
    an=an|{no+W}
  elif no>W*(H-1):
    an=an|{no-W}
  else:
    an=an|{no+W,no-W}
  return an
def longest(r,c):
  if S[r][c]=='.':
    cand=[]
    ted={}
    ted=set(ted)
    ted=ted|{W*(r-1)+c}
    cand=list(mawari(r,c))
    While cand!=[]:
      new=cand[0]
      cand=cand[1:]
      if S[new//W+1][new%W]=='.' and new not in ted:
        ted=ted|{new}
        cand=cand+[list(mawari((new//W+1),new%c)-ted)]
        
