from string import ascii_uppercase

# from pprint import pprint

def matrix_1():
    tmatrix = [[1, 1, 1, 1], [1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0], [1, 0, 0, 0]]
    # row, col = map(int, input().split())
    # matrix = [list(map(int, input().split())) for i in range(row)]
    matrix = tmatrix
    row, col = 5, 4
    for i in range(1, row):
        for j in range(1, col):
            matrix[i][j] = matrix[i][j-1] + matrix[i-1][j]
    for row in matrix:
        for elem in row:
            print(elem, end=' ')
        print()

# matrix_1()

"""
[0, 0, 0, 1]
[0, 0, 0, 1]
[0, 0, 0, 1]
[0, 0, 0, 1]
[1, 1, 1, 1]
"""

def matrix_2():
    tmatrix = [[0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1], [0, 0, 0, 1], [1, 1, 1, 1]]
    # row, col = map(int, input().split())
    # matrix = [list(map(int, input().split())) for i in range(row)]
    matrix = tmatrix
    row, col = 5, 4
    for i in range(row-2, -1, -1):
        for j in range(col-2, -1, -1):
            matrix[i][j] = matrix[i][j+1] + matrix[i+1][j]
    for row in matrix:
        for elem in row:
            print(elem, end=' ')
        print()

# matrix_2()

def matrix_3():
    row, col = map(int, input().split())
    cnt = 0
    matrix = []
    flag = False
    for i in range(0, row):
        row_array = []
        for j in range(0, col):
            row_array.append(cnt)
            cnt += 1
        if flag == False:
            matrix.append(row_array)
            flag = True
        else:
            row_array.reverse()
            matrix.append(row_array)
            flag = False
    for row in matrix:
        for elem in row:
            print(elem, end=' ')
        print()

# matrix_3()

def matrix_4():
    # row, col = map(int, input().split())
    # matrix = [list(input().split()) for i in range(row)]
    row, col = 3, 2
    tmatrix = [['W', 'W'], ['W', 'M'], ['B', 'B']]
    matrix = tmatrix
    if (any([i == 'C' or i == 'M' or i == 'Y' for row in matrix for i in row])) == False:
        print('#Black&White')
    else:
        print('#Color')

# matrix_4()

def matrix_5():
    n = int(input())
    matrix = [[0]*n for i in range(n)]
    i = 1
    x = 0
    y = -1
    d_row = 0 # -1, 0, 1
    d_col = 1 # -1, 0, 1
    length = len(str(n**2))
    while i <= n**2:
        if 0<=x+d_row<n and 0<=y+d_col<n and matrix[x+d_row][y+d_col] == 0:
            x += d_row
            y += d_col
            matrix[x][y] = i
            i += 1 
        else:
            if d_col == 1:
                d_col = 0
                d_row = 1
            elif d_row == 1:
                d_row = 0
                d_col = -1
            elif d_col == -1:
                d_col = 0
                d_row = -1
            elif d_row == -1:
                d_row = 0
                d_col = 1

    for row in matrix:
        for elem in row:
            print(str(elem).rjust(length), end=' ')
        print()

# matrix_5()


def matrix_6():
    # test_m = [['S', '.', '.'], ['S', '.', '.'], ['S', '.', '.'], ['S', '.', '.'], ['S', '.', '.'], ['S', '.', '.'], ['S', '.', '.']]
    # row, col = 7, 3
    row, col = map(int, input().split())
    m = [list(input()) for i in range(row)]
    cell = 0
    flag = False

    for string in m:
        for letter in string:
            if letter == 'S':
                flag = True
                continue
        if flag == False:
            cell += col
            for i in range(col):
                string[i] = 1
        flag = False
    
    for i in range(col):
        for j in range(row):
            if m[j][i] == 'S':
                flag = True
                continue
        if flag == False:
            for k in range(row):
                if m[k][i] != 1:
                    cell += 1
        flag = False

    print(cell)



matrix_6()

# a, b = 3, 1
# print([i for i in range(a, b-1, -1)])

# st = 'Create a list of the first letters of every word in this string'
# print([i[0] for i in st.split()])

# n = int(input())
# print([ascii_uppercase[i]*(i+1) for i in range(n)])



# test_m = [['S', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', 'S', '.']]

