h,w = map(int,input().split())

d={}
n=0

def f(i,j):
  if "{}{}".format(i,j) in d:
    if d["{}{}".format(i,j)]==".":
      return 1
    else:
      return 0
  else:
    return 0

for i in range(h):
  s=input()
  for j in range(w):
    d["{}{}".format(i,j)]=s[j]

t=0
for i in range(h):
  for j in range(w):
    if d["{}{}".format(i,j)]==".":
      p=0
      p=p+f(i+1,j)
      p=p+f(i,j+1)
      p=p+f(i-1,j)
      p=p+f(i,j-1)
      if p>0:
        t=t+1
    
print(t-1)
    