H, W = map(int,input().split())
square = []
for i in range(H):
    squaread = ['#']
    squaread+=(list(input()))
    squaread+=('#')
    square.append(squaread)
ad_square = [['#' for i in range(W+2)]]
ad_square += square
ad_square += [['#' for i in range(W+2)]]
numbersquare =[]
for i in range(H):
    numbersquare.append([0 for j in range(W)])
for i in range(H):
    i2 = i+1
    for j in range(W):
        j2 = j+1
        around = 0
        if ad_square[i2][j2]=='#':
            pass
        else:
            if ad_square[i2][j2-1]=='#':
                around += 1
            if ad_square[i2][j2+1]=='#':
                around += 1
            if ad_square[i2-1][j2]=='#':
                around += 1
            if ad_square[i2+1][j2]=='#':
                around += 1
            numbersquare[i2-1][j2-1] = around
number1 = 0
number2 =0
number3 =0
for i in range(len(numbersquare)):
    number2+=numbersquare[i].count(2)
    number3+=numbersquare[i].count(3)
print(sum([number2,number3]))