import sys
input = sys.stdin.readline

H,W = (int(x) for x in input().rstrip('\n').split())

m = []
for i in range(H):
  S = list(input().rstrip('\n'))
  m.append(S)
res = 0
for x in range(W):
  for y in range(H):
    if m[y][x]=='.':
      res_n = 0
      ok = [(x,y)]
      used = []
      while len(ok) > 0 :
        ok_n = []
        for X,Y in ok:
          next = [(X+1,Y),(X-1,Y),(X,Y-1),(X,Y+1)]
          next = [i for i in next if all([i[0]>=0,i[0]<W,i[1]<H,i[1]>=0])]
          next = [i for i in next if i not in used]
          next = [i for i in next if m[i[1]][i[0]] == '.']
          ok_n.extend(next)