rows, columns = map(int, raw_input().split())
cells = []
for rowN in range(rows): cells.append(list(raw_input()))
result = 0
for i in range(rows):
    flag = True
    for j in range(columns):
        if cells[i][j] == 'S':
            flag = False
            break
    if flag:
        for j in range(columns):
            cells[i][j] = 'x'
for j in range(columns):
    flag = True
    for i in range(rows):
        if cells[i][j] == 'S':
            flag = False
            break
    if flag:
        for i in range(rows):
            cells[i][j] = 'x'
for i in range(rows):
    for j in range(columns):
        if cells[i][j] == 'x': result += 1
print result

r,c=map(int,input().split())
mm=r*c
mat=[]
for i in range(r):
    s=input()
    mat.append(s)
ans=0
rr=0;cc=0;s=0
for i in range(r):
    for j in range(c):
        if mat[i][j]=='S':
            rr+=1
            break
for i in range(c):
    for j in range(r):
        if mat[j][i]=='S':
            cc+=1
            break
for i in range(r):
    for j in range(c):
        if mat[i][j]=='S':
            s+=1

print(r*c-rr*cc)

'''input
2 2
..
..
'''
r, c = map(int, input().split())
nr, nc = [], []
for x in range(r):
	n = list(input())
	if "S" in n:
		i = [j for j, k in enumerate(n) if k == "S"]
		nr.append(x)
		for z in i:
			nc.append(z)
a, b = len(set(nr)), len(set(nc))
print((r-a)*c + (c-b)*r - (r-a)*(c-b))

def main():
	r,c= [int(i) for i in input().split()]
	erow=[]
	ecol=[]
	count=0
	for i in range(r):
		s=input()
		for col in range(c):
			if s[col]=='S':
				erow.append(i)
				ecol.append(col)

	for i in range(r):
		for j in range(c):

			if i in erow and j in ecol:
				pass
			else:
				count+=1
	print(count)

	return 0

if __name__ == '__main__':
	main()

r,c=map(int,input().split())
mm=r*c
mat=[]
for i in range(r):
    s=input()
    mat.append(s)
ans=0
rr=0;cc=0;s=0
for i in range(r):
    for j in range(c):
        if mat[i][j]=='S':
            rr+=1
            break
for i in range(c):
    for j in range(r):
        if mat[j][i]=='S':
            cc+=1
            break
for i in range(r):
    for j in range(c):
        if mat[i][j]=='S':
            s+=1
r-=rr
c-=cc
if s==0:
    print(r*c)
else:
    print(mm-rr*cc)

r,c=map(int, input().split())
x=set()
y=set()

for i in range(r):
    t = [k for k in list(input())]

    for j in range(c):
        if t[j] == 'S':
            x.add(j)
            y.add(i)

print(r*c-(len(x)*len(y)))

r,c = map(int,raw_input().split())
l=[]
rcount,ccount=0,0
for x in range(r):
    temp=raw_input()
    l.append(temp)
    flag=0
    for y in range(c):
        if(l[x][y]=='S'):
            #rcount+=1
            flag=1
    if(flag==0):
        rcount+=1
for x in range(c):
    flag=0
    for y in range(r):
        if(l[y][x]=='S'):
            flag=1
    if(flag==0):
        ccount+=1
print (rcount*c)+(r*ccount)-(rcount*ccount)

import sys

hulp=sys.stdin.readline().split()
r,c=int(hulp[0]),int(hulp[1])
regel=[True,True,True,True,True,True,True,True,True,True]
kolom=[True,True,True,True,True,True,True,True,True,True]

for x in range (r):
    line=sys.stdin.readline().strip()
    for y in range(len(line)):
        if line[y]=='S':
            regel[x]=False
            kolom[y]=False

fr=0
fc=0
for x in range(10):
    if regel[x]==False:
        fr+=1
    if kolom[x]==0:
        fc+=1

print r*c-fr*fc

r,c=[int(i) for i in raw_input().split()]
l=[]
eat=0
for i in range(r):
    l.append(raw_input())
for i in range(r):
    if "S" not in l[i]:
        eat+=l[i].count('.')
        l[i]='1'*c
for i in range(c):
    s=[g[i] for g in l]
    if "S" not in s:
        eat+=s.count('.')
print eat

r,c=map(int,input().split())
co=0
lis=[]
for i in range(r):
    st=input()
    for i in range(c):
        if st[i]=="S":
            lis.append(i)
    for i in range(c):
        if st[i]=="S":
            co+=1
            break
if len(lis)>0:
    lis=set(lis)
print((r*c)-(len(lis)*co))

r ,c = map(int ,input().split())
dd =[]
for i in range(r):
    s = input()
    op = []
    for ii in s:
        op.append(ii)
    dd.append(op)
s1 ='S'
r_1 =0

for i in range(r):
    if s1 not in dd[i]:
        r_1+=c
        for j in range(c):
            dd[i][j]=-1

ans =[]
op =[]
for ii in range(c):
    c_1 =0
    k=0
    for jj in range(r):
        if dd[jj][ii] != s1:
            if dd[jj][ii]==-1:
                k+=1
                c_1+=1
            else:c_1+=1
    if c_1 ==r:

        ans.append(c_1)
        op.append(k)
so = sum(ans)
ko = sum(op)

print((so+r_1)-ko)

def eat(cake, r, c):
    for i in range(r):
        cake[i] = [['E']*c, cake[i]]['S' in cake[i]]

r, c = map(int, raw_input().split())
cake = [list(raw_input()) for _ in [0]*r]
eat(cake, r, c)
cake = map(list, zip(*cake))
eat(cake, c, r)
print sum(cake, []).count('E')

__author__ = 'user'
r, c = map(int, raw_input().split())
l = []
for i in xrange(r):
    l.append(list(raw_input().strip()))
res = 0
def fl(tl):
    global res
    for i in tl:
        tres = 0
        if i.__contains__("S"):
            continue
        for k in xrange(len(i)):
            j = i[k]
            if j == ".":
                tres += 1
                i[k]="-"
        if tres!=-1:
            res+=tres
fl(l)
fl(map(list, zip(*l)))
print res

r,c = map(int,input().split())
x = r * [0]
y = c * [0]
count = 0
for i in range(r) :
    s = input()
    for j in range(c) :
        if s[j] == 'S' :
            x[i] = 1
            y[j] = 1
a = x.count(1)
b = y.count(1)

print(r*c - a*b)

r, c = map(int,input().split(' '))
count = 0
A = []
x = 0

for i in range(r):
    n = list(input())

    if 'S' not in n:
        x += 1

    A.append(n)

y = []
p = 0

for i in range(c):
    for j in range(r):
        y.append(A[j][i])

    if 'S' not in y:
        p += 1

    y = []

count = r*c - (r-x)*(c-p)

print(count)

R=raw_input
b=map(R," "*int(R()[:2]))
print ' '*100000
S=lambda b:sum('S'in i for i in b)
print int(len(b)*len(b[0]) - S(b)*S(zip(*b)))

r, c = map(int, input().split())
lst = [[s for s in input()] for _ in range(r)]
count, col = 0, set()
for i in range(r):
    if 'S' not in lst[i]:
        count += 1
    for j in range(c):
        if lst[i][j] == 'S':
            col.add(j)
print((c - len(col)) * (r - count) + count * c)

R=raw_input
b=map(R," "*int(R()[:2]))
S=lambda b:sum('S'in i for i in b)
print len(b)*len(b[0])-S(b)*S(zip(*b))

def make_cake(nb_row, nb_col):
    cake = [[0]*nb_col for _ in range(nb_row)]

    for i in range(nb_row):
        row = raw_input()
        for j, cell in enumerate(row):
            cake[i][j] = 1 if cell == '.' else 0

    return cake

if __name__ == '__main__':
    nb_row, nb_col = [int(num) for num in raw_input().split()]

    cake = make_cake(nb_row, nb_col)

    edible_rows, edible_cols = [1]*nb_row, [1]*nb_col
    for i in range(nb_row):
        for j in range(nb_col):
            edible_rows[i] &= cake[i][j]
            edible_cols[j] &= cake[i][j]

    edible_rows = [i for i, edible in enumerate(edible_rows) if edible]
    edible_cols = [i for i, edible in enumerate(edible_cols) if edible]

    nb_eat = 0
    for i in edible_rows:
        for j in range(nb_col):
            nb_eat += not cake[i][j] == -1
            cake[i][j] = -1

    for j in edible_cols:
        for i in range(nb_row):
            nb_eat += not cake[i][j] == -1
            cake[i][j] = -1

    print nb_eat

r, c = map(int, raw_input().split())
s, a = [], [([0] * c) for i in range(r)]
for i in range(r):
	s.append(raw_input())
	if s[i] == '.' * c:
		a[i] = [1] * c
for j in range(c):
	for i in range(r):
		if s[i][j] == 'S':
			break
	else:
		for i in range(r):
			a[i][j] = 1
print sum(sum(a[i]) for i in range(r))

def main():
    r,c = map(int, input().split())
    cake = [input() for _ in range(r)]
    neigh = []
    for y in range(r):
        for x in range(c):
            if not 'S' in cake[y]:
                neigh.append(tuple(range(y * c, y * c + c)))
            if all('S' != _[x] for _ in cake):
                neigh.append(tuple(range(x, r * c, c)))
    field = [_ == '.' for s in cake for _ in s]
    start = sum(field)
    if any(neigh):
        while True:
            nn = max(neigh, key=lambda e: sum(field[_] for _ in e))
            if not sum(field[_] for _ in nn):
                break
            for i in nn:
                field[i] = False
    print(start - sum(field))

main()

d,n=list(map(int,input().split()))
c=l=k=0
a=[]
for i in range(d):
    s=input()
    if "S" not in s:
        l+=1
        c+=n
    a.append(s)
m=[]
for j in range(n):
    v=""
    for t in a:
        v=v+t[j]
    m.append(v)
for f in m:
    if "S" not in f:
        k+=1
        c+=d
print(c-(k*l))

def answer():
    a = input().split()
    a = [int(x) for x in a]
    i=0
    c=[]
    d1=[]
    while i<a[0]:
        d=list(input())
        j=0
        while j<len(d):
            if d[j]=="S":
                if i not in c:c.append(i)
                if j not in d1:d1.append(j)
            j+=1
        i+=1
    ans = a[0]*a[1]-len(c)*len(d1)
    print(ans)
answer()

from __future__ import print_function
import sys

def main():
	vstup=(sys.stdin.readline()).split(" ")
	r=int(vstup[0])
	c=int(vstup[1])
	chocolate=[]

	for i in range(r):
		chocolate.append(list(sys.stdin.readline()))
	count=c*r

	for i in range(r):
		for j in range(c):
			if chocolate[i][j]=='S':
				count-=c
				break
	s=count/c

	for j in range(c):
		for i in range(r):
			if chocolate[i][j]=='S':
				break
			if i==r-1 and chocolate[r-1][j]!='S':
				count+=r-s
	print(count)

if __name__ == "__main__":
	main()

n, m = map(int,raw_input().split())
l = []
for i in range(n):
	l.append(list(raw_input()))
c = 0
for i in range(n):
	for j in range(m):
		if l[i][j] == 'S':
			continue
		h, v = 0, 0
		x, y = i, j-1
		while 0 <= x < n and 0 <= y < m:
			if l[x][y] == 'S':
				v = 1
			y -= 1
		x, y = i-1, j
		while 0 <= x < n and 0 <= y < m:
			if l[x][y] == 'S':
				h = 1
			x -= 1
		x, y = i+1, j
		while 0 <= x < n and 0 <= y < m:
			if l[x][y] == 'S':
				h = 1
			x += 1
		x, y = i, j+1
		while 0 <= x < n and 0 <= y < m:
			if l[x][y] == 'S':
				v = 1
			y += 1
		if h == 1 and v == 1:
			continue
		c += 1
print c

n, m = map(int, input().split())
tort=[input() for i in range(n)]
x='S'
mas=[[False]*m for i in range(n)]

for i in range(n):
    if 'S' not in tort[i]:
        for j in range(m):
            mas[i][j]=True
for j in range(m):
    is_find=False
    for i in range(n):
        if tort[i][j]=='S':
            is_find=True
            break
    if not is_find==True:
        for i in range(n):
            mas[i][j]=True
count=0

for row in mas:
    count+=row.count(True)
print(count)

R=raw_input
b=map(R," "*int(R()[:2]))
S=lambda b:sum('S'in i for i in b)
print int(len(b)*len(b[0]) - S(b)*S(zip(*b)))

n,m=map(int,input().split())
l=[input() for _ in range(n)]
from collections import Counter
s=[]
k=0
for i in range(n):
    if 'S' not in l[i]:
        k=k+1
    for j in range(m):
        if l[i][j]=='S':
            s.append(j+1)
x=len(Counter(s))
print(k*m+(m-x)*n-k*(m-x))

import itertools
from fractions import gcd
from math import sqrt
from bisect import bisect_left
import heapq
from collections import deque , defaultdict,Counter
from itertools import combinations as C
def Ls():
	return list(raw_input())
def get(a):
	return map(a , raw_input().split())
def Int():
	return int(raw_input())
def Str():
	return raw_input()
a , b = get(int)
h = []
row = 0
grid = []
for j in xrange(a):
	h.append(Ls())
	grid.append(h[j])
	if h[j].count('S') == 0:
		row += 1
		grid[j] = ['1']*b
col = 0
#print grid
for j in xrange(b):
	cnt = 0
	for i in xrange(a):
		if h[i][j] == '.':
			cnt += 1
	if cnt == a:
		for i in xrange(a):
			grid[i][j] = '1'
#print grid
ans = 0
for i in xrange(a):
	for j in xrange(b):
		if grid[i][j] == '1':
			ans += 1
print ans

n, p = map(int, input().split())
arr = []
for i in range(n):
    s = str(input())
    arr.append(s)

count = 0
countExtra = 0
for i in range(n):
    counts = 0
    k = 0
    truth = True
    while k < p and truth == True:
        if arr[i][k:k+1] == ".":
            counts+=1
        if arr[i][k:k+1] == "S":
            truth = False
        k+=1
    if counts == p:
        count+=counts
        countExtra+=1

for i in range(p):
    countss = 0
    kk = 0
    truthh = True
    while kk < n and truthh ==True:
        if arr[kk][i:i+1] == ".":
            countss+=1
        if arr[kk][i:i+1] == "S":
            truthh = False
        kk+=1
    if countss == n:
        count+=countss
        count-=countExtra
print(count)

def stri(t,a,b):
    l=0
    for i in range(b):
        if t[i]=="S":
            a[i]=1
            l=-1
    if l==0:
        return 0
    else:
        return -1

a,b=map(int,input().split())
r=[0]*a
c=[0]*b
for i in range(a):
    k=input()
    t=stri(k,c,b)
    if t==-1:
        r[i]=1

m=r.count(0)
n=c.count(0)
print(m*b+n*a-m*n)

n,m = input().split()
m = int(m)
s=''
ans = 0
for i in range(int(n)):
    temp = str(input())
    if 'S' not in temp:
        ans = ans+m
        temp=''
    s = s + temp
for j in range(int(m)):
    temp = ''
    while j<len(s):
        temp = temp + s[j]
        j = j+int(m)
    if 'S' not in temp:
        ans = ans +  len(temp)
print(ans)

import sys
input = sys.stdin.readline

############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))

def solution(mat,r,c):
    total = 0
    cnt = 0
    for i in range(r):
        res = 0
        for j in range(c):
            if mat[i][j] == 'S':
                res = 0
                break
            else:
                res += 1
        total += res
        if res > 0:
            cnt += 1
    dep = 0
    for j in range(c):
        res = 0
        for i in range(r):
            if mat[i][j] == 'S':
                res = 0
                break
            else:
                res += 1
        total += res
        if res > 0:
            dep += 1
    return (total - dep*cnt) if total >= 0 else 0

r,c = invr()
mat = []
for i in range(r):
    s = insr()
    mat.append(s)
print(solution(mat,r,c))

r,c=map(int,input().split());a=[input() for _ in[0]*r]
s=lambda x:sum(i.count('S')>0 for i in x)
print(r*c-s(a)*s(zip(*a)))

r,c = map(int,input().split())
data = [list(input()) for i in range(r)]

total=0
for i in range(r):
    if 'S' not in data[i]:
        total+=c
row = total//c
for j in range(c):
    for k in range(r):
        if data[k][j]=='S':
            break
    else:
        total=total+r-row
print(total)

def fun(n,m,li):
   eatrow=[]
   noteatcolumn=[]
   for i in range(n):
       fi=[]
       for j in range(m):
           if li[i][j]=='S':
               fi.append(j)
       if len(fi)>0:
           noteatcolumn.extend(fi)
           continue
       else:
           eatrow.extend([(i,j) for j in range(m)])
   eat=set(range(m))-set(noteatcolumn)
   for j in eat :
            eatrow.extend([(i,j) for i in range(n)])
   print(len(set(eatrow)))

n,m=list(map(lambda x:int(x),input().split()))
li=[input() for i in range(n)]
fun(n,m,li)

a,b=map(int,input().split())
c=[]
d=[]
for i in range(a):
    z=list(input())
    for j in range(b):
        if z[j]=='S':
            c.append(i)
            d.append(j)
print(a*b-len(list(set(c)))*len(list(set(d))))

import math

def main():
    r, c = map(int, input().split())
    g = [[] for _ in range(r)]
    for row in range(r):
        g[row] = list(input())

    for row in range(r):
        if not 'S' in g[row]:
            for col in range(c):
                g[row][col] = '*'

    for col in range(c):
        ok = True
        for row in range(r):
            if g[row][col] == 'S':
                ok = False
                break
        if ok:
            for row in range(r):
                g[row][col] = '*'

    res = 0
    for row in range(r):
        for col in range(c):
            if g[row][col] == '*':
                res += 1
    print(res)

if __name__ == '__main__':
    main()

#!/usr/bin/python

r,c = map(int,raw_input().split())
count = 0
cake = []
indexr=0
indexc=0

for i in range(r):
        cake.append(raw_input())

for i in range(r):
        for j in cake[i]:
                 if j == 'S':
                        indexr = indexr + 1
                        break

count = (r - indexr)* c
for i in range(c):
        for j in range(r):
                if cake[j][i] == 'S':
                        indexc = indexc + 1
                        break
count = count + ((c - indexc)*r)
count = count - ((r-indexr) * (c - indexc))

print count

def solve():
    n,m=list(map(int,input().split()))
    l=list()
    for i in range(n):
        l.append(input())
    flag,row,col=1,0,0
    for i in range(n):
        for j in range(m):
            if(l[i][j]=="S"):
                flag=0
        if(flag):
            row+=1
        flag=1
    flag=1
    for i in range(m):
        for j in range(n):
            if(l[j][i]=="S"):
                flag=0
        if(flag):
            col+=1
        flag=1
    print(row*m+col*n-row*col)

#----------------------------------------------------------#

t=1
for _ in range(t):solve()

n, m = map(int, input().split())
a = []
for i in range(n):
    b = list(input())
    a.append(b)

s = 0
z = 0
for i in range(n):
    if "S" not in a[i]:
        z += 1
        s += len(a[i])

for i in range(m):
    d = []
    for j in range(n):
        d.append(a[j][i])
    if "S" not in d:
        s += len(d)-z

print(s)

r,c=map(int,input().split())
mat=[]
for i in range(r):
    mat.append(list(input()))
rw=[];cl=[]
for i in range(r):
    for j in range(c):
        if mat[i][j]=="S":
            rw.append(i)
            cl.append(j)
k=0
for i in range(r):
    for j in range(c):
        if i in rw and j in cl:
            k+=1
print(r*c-k)

#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Thu Jan 18 20:49:56 2018

@author: alexis
"""

row, col = raw_input().split()

row = int(row)
col = int(col)

grid = []
eaten = 0

for i in range(row):
    grid.append(raw_input())

#print grid

temp_grid = grid[:]
for row in grid:
    if "S" not in row:
        eaten += col

        temp_grid.remove(row)

#print temp_grid

for each in range(0, col):
    j = ""
    for row in temp_grid:
        j += row[each]

    if "S" not in j:
        eaten += len(temp_grid)

print eaten

#3 4
#S...
#....
#..S.

"""http://codeforces.com/problemset/problem/330/A"""

def solve(cake):
    rows, collumns = set(), set()
    for i, row in enumerate(cake):
        for j, cell in enumerate(row):
            if cell == 'S':
                rows.add(i)
                collumns.add(j)

    res = 0
    for i, row in enumerate(cake):
        for j, cell in enumerate(row):
            if cell == 'S':
                continue
            if i not in rows or j not in collumns:
                res += 1
    return res

if __name__ == '__main__':
    r, c = map(int, input().split())
    l  = []
    for _ in range(r):
        l.append(input())
    print(solve(l))

"""http://codeforces.com/problemset/problem/330/A"""

def solve(r, c, cake):
    rows, collumns = set(), set()
    for i, row in enumerate(cake):
        for j, cell in enumerate(row):
            if cell == 'S':
                rows.add(i)
                collumns.add(j)

    # res = 0
    # for i, row in enumerate(cake):
    #     for j, cell in enumerate(row):
    #         if cell == 'S':
    #             continue
    #         if i not in rows or j not in collumns:
    #             res += 1
    # return res
    return (r * c) - (len(rows) * len(collumns))

if __name__ == '__main__':
    r, c = map(int, input().split())
    l  = []
    for _ in range(r):
        l.append(input())
    print(solve(r, c, l))

n,m=map(int,input().split())
l=[]
c=0
for i in range(n):
	s=input()
	if 'S' not in s:
		c+=m
	else:
		l.append(s)
for i in range(m):
	s1=0
	for j in range(len(l)):
		if l[j][i]!='S':
			s1+=1
		else:
			s1=0
			break
	c+=s1
print(c)

r, c = map(int, input().split())

x = r * [0]
y = c * [0]

for i in range(r):
    s = input()
    for j in range(c):
        if (s[j] == 'S'):
            x[i] = 1
            y[j] = 1

a = x.count(1)
b = y.count(1)

print(r * c - a * b)

r,c=map(int,input().split())
q,w=0,0
for i in range(r):
    s=input().replace(".","0").replace("S","1")
    if "1" not in s:q+=c;r-=1
    w=w|int(s,2)
w=bin(w)[2:]
print(q+r*(w.count("0")+c-len(w)))

r,c=map(int,input().split())
a=[]
rapple=0
capple=0
for i in range(r):
    n=input()
    if ('S' in n):
        rapple+=1
    a.append(list(n))
for i in range(c):
    for j in range(r):
        if (a[j][i]=='S'):
            capple+=1
            break
ans=(r*c-(rapple*capple))
if ans>=0:
    print (ans)
else:
    print (0)

n, m = [int(i) for i in input().split()]
r = [True]*n
c = [True]*m
a = []
k = 0
for i in range(n):
    a.append(input())
for i in range(n):
    for j in range(m):
        if a[i][j] == 'S':
            r[i] = c[j] = False
sr = 0
sc = 0
for i in r:
    if i:
        k += m
        sr += 1
for i in c:
    if i:
        k += n
        sc += 1
print(k - sc * sr)

r, c = map(int, input().split())
cake = []
for i in range(r):
    cake.append(list(input()))
res = 0
for i in cake:
    if 'S' not in i:
        res += c
        for j in range(len(i)):
            i[j] = None
for i in range(c):
    f = 1
    for j in range(r):
        if cake[j][i] == 'S':
            f = 0
            break
    if f:
        for j in range(r):
            if cake[j][i] is not None:
                res += 1
print(res)

r,c = map(int,input().split())
l1 = [input() for i in range(r)]
l,c1,c2 = [],0,0
for i in range(r):
	if 'S' in l1[i]:
		c1+=1
for j in range(c):
	for i in range(r):
		if l1[i][j]=='S':
			c2+=1
			break
print(c*(r-c1)+r*(c-c2)-(r-c1)*(c-c2))

r,c = map(int,input().split())
h = [1]*c
l = []
for i in range(r):
    l.append(input())
m = []
for i in range(c):
    x = ''
    for j in range(r):
        x+=l[j][i]
    m.append(x)
cc,cr = 0,0
ans = 0
for i in range(r):
    if(l[i].find('S')==-1):
        ans+=c-cc
        cr+=1
    else:
        for j in range(c):
            if(l[i][j]=='.'):
                if(h[j] and m[j].find('S')==-1):
                    ans+=r-cr
                    cc+=1
                    h[j] = 0
print(ans)

r,c=map(int,input().split())
l=[]
re,ce,e=0,0,0
for i in range(r):
    x=input()
    if "S" not in x:
        re+=1
        e+=c
    l.append(x)
for i in range(c):
    f=False
    for j in range(r):
        if l[j][i] == "S":
            f=True
    if not f:
        ce+=1
        e+=r
print(e-(re*ce))

r,c=input().split()
r=int(r)
c=int(c)
arr=[]
rp=0
sum=0;
col_set=[]
for i in range(r):
    arr.append(input())
    try:
        arr[i].index('S')
        for j in range(len(arr[i])):
            if arr[i][j]=='S':
                col_set.append(j)

    except:
        rp+=1
        sum+=c

for i in range(c):
    if i not in col_set:
        sum=sum+r-rp
print(sum)

r, c = map(int, raw_input().split())

n = [True] * r
m = [True] * c

for i in range(r):
        j = 0
        for e in raw_input():
                if e == 'S':
                        n[i] = False
                        m[j] = False
                j += 1

a = sum(map(int, n))
b = sum(map(int, m))

print a * c + b * r - a * b

n,m=map(int,input().split())
a=[]
c=[]
ans=0
for i in range(n):
    b=list(input())
    if not "S" in b:
        ans+=m
        for i in range(len(b)):
            b[i]="P"
        a.append(b)
    else:
        a.append(b)
b=[]
for i in range(m):
    for j in range(n):
        b.append(a[j][i])
    if not "S" in b:
        for i in range(len(b)):
            if b[i]!="P":
                ans+=1
    b=[]
print(ans)

import sys
r,c=sys.stdin.readline().split()
r = int(r)
c= int(c)
rr = set(range(r))
cc = set(range(c))
l = 0
for i in sys.stdin.readlines():
    for j in range(len(i)):
        if i[j] == 'S':
            if l in rr:
                rr.remove(l)
            if j in cc:
                cc.remove(j)
        #print '*'
    l+=1
print len(cc)*r+c*len(rr)-len(cc)*len(rr)

#
#   330A. Cakeminator
#

rows, columns = map(int, raw_input().split())
cake_matrix = [['' for c in range(columns)] for r in range(rows)]
for i in range(rows):
    s = raw_input()
    for j in range(len(s)):
        cake_matrix[i][j] = s[j]
row_count = sum(int('S' in cake_matrix[i]) for i in range(rows))
transpose_cake_matrix = zip(*cake_matrix)
column_count = sum(int('S' in transpose_cake_matrix[i]) for i in range(columns))
print rows * columns - row_count * column_count

string = raw_input().split(' ')
string = map(lambda x:int(x),string)
rows = []
columns = []
for i in range(string[0]):
	temp = raw_input()

	loc = [y for y,x in enumerate(temp) if x=='S']

	for v in loc:
		rows.append(i)
		columns.append(v)

print (-string[0]+len(set(rows)))*(string[1]-len(set(columns)))+(string[1]-len(set(columns)))*string[0]+(string[0]-len(set(rows)))*string[1]

ip_l = map(int, raw_input().strip().split())
r = ip_l[0]
c = ip_l[1]
r_l = range(r)
c_l = range(c)
for i in range(r):
    s = raw_input().strip()
    for j in range(c):
        if(s[j] == 'S'):
            if(i in r_l):
                r_l.remove(i)
            if(j in c_l):
                c_l.remove(j)
# print r_l
# print c_l

visited = []
for i in r_l:
    for j in range(c):
        visited.append((i, j))
for i in range(r):
    for j in c_l:
        if((i, j) not in visited):
            visited.append((i, j))

print len(visited)

x,y=map(int,input().split());a=[];b=['.' for i in range(y)];p=0;q=0
for i in range(x):
	a.append(input())
for i in range(y):
	for t in range(x):
		b[i]=b[i]+a[t][i]
for i in range(x):
	if a[i].count('S')==0:
		p=p+y
if p>0:
	x=x-(p//y)
for i in range(y):
	if b[i].count('S')==0:
		q=q+x
print(p+q)
#author:SK__Shanto__㋛
#code__define__your__smartness

R=raw_input
b=map(R," "*int(R()[:2]))
S=lambda b:sum('S'in i for i in b)
print len(b)*len(b[0])-S(b)*S(zip(*b))

r,c = map(int, raw_input().split())

mx = [raw_input() for _ in xrange(r)]

rows=set()
cols=set()

for i in xrange(r):
	for j in xrange(c):
		if mx[i][j]=='S':
			rows.add(i)
			cols.add(j)

ans=0
for i in xrange(r):
	for j in xrange(c):
		if i not in rows or j not in cols:
			ans+=1

print ans

r, c = list(map(int, input().split()))
l = []
a = []
for i in range(r):
    l.append(input())
cnt = 0

for ix, row in enumerate(l):
    if 'S' not in row:
        cnt += c
        a.append(ix)

i = j = 0

while j < c:
    cn = i = 0
    while i < r:
        if i in a:
            i += 1
            continue
        if l[i][j] == 'S':
            break
        else:
            cn += 1
        i += 1
    else:
        cnt += cn
    j += 1

print(cnt)

n,m = map(int,raw_input().strip().split(' '))
l=[]
count = 0
countr = 0
countc = 0
for i in range(n):
    l.append(raw_input().strip())
    if 'S' not in l[i]:
        count += m
        countr += 1

for j in range(m):
    flag = True
    for i in range(n):
        if l[i][j] == 'S':
            flag = False
            break
    if flag:
        count += n
        countc += 1
print count - countr*countc

#import sys
#input = sys.stdin.readline
rows,columns=map(int,input().strip().split())
matrix=[[0 for x in range(columns)] for y in range(rows)]
#print(matrix)
for i in range(rows):
    n=list(input())
    for j in range(len(n)):
        matrix[i][j]=n[j]
k=0
for i in range(rows):
    c=0
    for j in range(columns):
        if matrix[i][j]!='S':
            c+=1
    if c==columns:
        for j in range(columns):
            k+=1
            matrix[i][j]='v'
#print(matrix)
for i in range(columns):
    c=0
    for j in range(rows):
        #print(matrix[j][i])
        if matrix[j][i]!='S':
            c+=1
    if c==rows:
        for j in range(rows):
            if matrix[j][i]!='v':
                k+=1
print(k)

n, m = map(int,input().split())
a = []
for i in range(n):
	a.append(list(input()))
s = 0
s1 = 0
for i in range(n):
	count = 0
	for j in range(m):
		if a[i][j] == ".":
			count += 1
	if count == m:
		s += m
		s1 += 1
for i in range(m):
	count = 0
	for j in range(n):
		if a[j][i] == ".":
			count += 1
	if count == n:
		s += (n - s1)
print(s)

r,c=raw_input().split()
r=int(r)
c=int(c)
l=[]
l1=[]
row=[]
column=[]
for i in range(r):
    l=[x for x in raw_input()]
    l1.append(l)
for i in range(r):
    for j in range(c):
        if(l1[i][j]=='S'):
            if i not in row:
                row.append(i)
            if j not in column:
                column.append(j)
#print row
#print column
n=len(column)*len(row)
r=int(r)
c=int(c)
ans=(r*c)-(n)
if(ans>0):
    print ans
else:
    print '0'

r,c=map(int,raw_input().split());cake=[]
for i in range(r):
    for j in raw_input():
        cake.append(ord(j))
for i in range(r):
    cake[i*c:(i+1)*c]=[cake[i*c:(i+1)*c],[99]*c][83 not in cake[i*c:(i+1)*c]]
for i in range(c):
    cake[i::c]=[cake[i::c],[99]*r][83 not in cake[i::c]]
print sum(1 for i in cake if i==99)

n, m = map(int, input().split())
li = []
ans = 0
for i in range(n):
    s = list(input())
    if 'S' not in s:
       ans += m
    else:
        li.append(s)
if(len(li)!=0):
    li2 = []
    for i in range(len(li[0])):
        x = []
        for j in li:
            x.append(j[i])
        if('S' not in x):
            ans += len(x)
print(ans)

r,c=map(int, input().split())
l=[[0]*c]*r
for i in range(r):
    l[i]=list(input())
#print(l)
cr=0
cc=0
for i in range(r):
    x=l[i]
    if 'S' not in x:
        cr+=1
for j in range(c):
    x=[l[i][j] for i in range(r)]
    if 'S' not in x:
        cc+=1
ans=max(cr*c+cc*r-cr*cc,0)
print(ans)

def tran(m):
    rez = [[m[j][i] for j in range(len(m))] for i in range(len(m[0]))]
    return rez
r,n = map(int,input().strip().split())
c = 0
b = 0
arr = []
for l in range(r):
    arr.append(list(input()))
for row in arr:
    if 'S' not in row:
        c += row.count('.')
        b += 1
arr = tran(arr)
for row in arr:
    if 'S' not in row:
        c += row.count('.') - b
print(c)

r, c = map(int, input().split())
list = []
cnt = 0

for k in range(r):
    g = input()
    list.append(g)

def foo_r(x, y):
    a = True
    if 'S' in list[x]:
        a = False

    b = foo_c(y)
    if a == False and b == False:
        return False
    else:
        return True

def foo_c(z):
    n = True
    for f in range(r):
        if list[f][z] == 'S':
            n = False
            break

    return n

for i in range(r):
    for j in range(c):
        if list[i][j] == 'S':
            continue
        else:
            x = foo_r(i, j)
            if x == True:
                cnt += 1

print(cnt)

r,c=map(int,input().split())
x=0
y=[]
for i in range(r):
    s=input()
    if 'S' in s:
        x+=1
    for j in range(len(s)):
        if 'S'==s[j] and j not in y:
            y.append(j)
print(r*c-x*len(y))

n,m=map(int,input().split())
s=""
a=set()
b=set()
for i in range(n):
    s=input()
    for j in range(m):
        if s[j]=='S':
            a.add(i)
            b.add(j)
print(m*n-len(a)*len(b))

a,b = map(int,input().split())
z,w,q =[],0,0
for i in range(a):
	l = list(input())
	z.append(l)
	if l.count("S")==0:w+=1
for i in range(len(z[0])):
	e =""
	for j in range(len(z)):
		e+=z[j][i]
	if e.count("S")==0:q+=(a-w)
print(w*b + q)

n,d = map(int,input().split(" "))
t1=[0]*n
t2=[0]*d
for i in range(n):
    j=0
    for s in input():
        if s=="S":
            t1[i]=1
            t2[j]=1
        j+=1
res=0
for i in range(n):
    for j in range(d):
        if t1[i]!=1 or t2[j]!=1:
            res+=1
print(res)

#-------------Program--------------
#----Kuzlyaev-Nikita-Codeforces----
#-------------Training-------------
#----------------------------------
r,c=map(int,input().split())
eat=0;f=[]
for i in range(c):f.append([])
for i in range(r):
    k=list(str(input()))
    if k.count("S")==0:
        for j in range(c):
            k[j]="E"
        eat+=c
    for j in range(c):
        f[j].append(k[j])
for i in range(c):
    if f[i].count("S")==0:
        eat+=f[i].count(".")
print(eat)

n,m = map(int,input().split())
lis=[]
for i in range(n):
    l = list(input())
    lis.append(l)
ans=0
for i in range(n):
    c=0
    for j in range(m):
        if lis[i][j]=='S':
            c=0
            break
        elif lis[i][j]=='.':
            c+=1
    if c>0:
        ans+=c
        for j in range(m):
            if lis[i][j]!='S':
                lis[i][j]=0
for i in range(m):
    c=0
    for j in range(n):
        if lis[j][i]=='S':
            c=0
            break
        elif lis[j][i]=='.':
            c+=1
    if c>0:
        ans+=c
        for j in range(n):
            if lis[j][i]!='S':
                lis[j][i]=0
print(ans)

n,m=map(int,input().split())
row=set()
col=set()
ans=0
for  i in range(n):
    s=input()
    for j in range(m):
        if s[j]=='S':
            row.add(i)
            col.add(j)
ans=n*m
x=len(row)*len(col)

print(ans-x)

r, c = map(int, input().split())
tort = [input() for i in range(r)]
count = 0
s = 0
z = 0
column = []
q = 0
for i in range(r):
    if 'S' not in tort[i]:
        count += c
        z += 1

    elif 'S' in tort[i] and tort[i].count('S') == len(tort[i]):
        s = 1
if (count == 0 and s == 0) or (count > 0 and s == 1) or (count > 0 and s == 0):
    for i in range(c):
        for j in range(r):
            if tort[j][i] == '.':
                q += 1
        column.append(q)
        q = 0
    if count > 0 and max(column) == r:
        print(count + max(column)*column.count(max(column)) - column.count(max(column))*z)
    elif count == 0 and max(column) == r:
        print(max(column)*column.count(max(column)))
    else:
        print(count)
else:
    print(0)

r,c=map(int,input().split())
a=[]
nr=[]
nc=[]
for i in range(r):
	p=list(input())
	for j in range(c):
		if p[j]=="S":
			if j not in nc:
				nc.append(j)
			if i not in nr:
				nr.append(i)
print(( (r-len(nr))*c )+( (c-len(nc))*r )- (r-len(nr))*(c-len(nc)) )

import fileinput as f

data = []

for line in f.input():
    if f.lineno() == 1:
        [r, c] = list(map(int, line.split()))
    else:
        data.append(line.strip())

Srows = [0] * r
Scols = [0] * c
for m in range(r):
    for n in range(c):
        if data[m][n] == 'S':
            Srows[m] = 1
            Scols[n] = 1

cr = sum(Srows)
cc = sum(Scols)
numcakes = r * c - cr * cc

print(numcakes)

r,c=map(int,input().strip().split())
l=[]
R=0
C=0
z=0
C1=set()
for i in range(r):
    l.append(input())
    if  l[i].find('S',0)== -1:
        z+=1
    else:
        R+=1
for i in range(r):
    for j in range(c):
        if l[i][j]=='S':
            C1.add(j)
C=len(C1)

print(r*c-R*C)

a,b=map(int,input().split())
l=[]
k=0
for i in range(a):
    l.append(input())
for i in range(a):
    if l[i].count('S')==0:
        k+=b
        l[i]='*'*b
for i in range(b):
    v = 0
    o=0
    for j in range(a):
        if l[j][i]=='.':
            v+=1
        elif l[j][i]=='*':
            o+=1
    if v+o == a:
        k+=v
print(k)

n,m=list(map(int,input().split()))
l=[]
for _ in range(n):
    l.append(list(input()))

c=0
pos=[]
for x in l:
    if 'S' not in x:
        c+=m
        l.remove(x)

nl= list(map(list, zip(*l)))
for x in nl:
    if 'S' not in x:
        c+=len(l)

print(c)

# import sys
# sys.stdin=open("input.in",'r')
# sys.stdout=open("output1.out",'w')
n,m=map(int,input().split())
a=[]
c=0
for i in range(n):
	s=input()
	if 'S' in s:
		c+=1
		c+=s.count("S")
print(n*m-c)

r,c=map(int,input().split())
A,B=[],[]
for i in range(r):
    R=list(input())
    while('S'in R):
        I=R.index('S')
        B+=[I]
        A+=[i]
        R[I]='.'
print((r*c)-sum(set(A))*sum(set(B)))

n, m = map(int, input().split())
a = []
[a.append(input()) for i in range(n)]
stroki = 0
stolb = 0
b = []
for j in range(m):
    bb = []
    for i in range(n):
        [bb.append(a[i][j])]
    b.append(' '.join(bb))
for ss in a:
    if 'S' not in ss:
        stroki += 1
for pp in b:
    if 'S' not in pp:
        stolb += 1
cc = []
for i in a:
    for j in i:
        cc.append(j)
        if 'S' not in cc:
            summa = n * m
        elif stroki == stolb:
            summa = (stroki * m + stolb * n) - max(stroki, stolb) * stroki
        elif stroki != 0 and stolb != 0:
            summa = (stroki * m + stolb * n) - max(stroki, stolb)
        else:
            summa = (stroki * m + stolb * n)
print(summa)

'''input
3 4
S...
....
..S.
'''
r, c = map(int, input().split())
nr, nc = [], []
for x in range(r):
	n = input()
	if "S" in n:
		nr.append(x)
		nc.append(n.index("S"))
a, b = len(set(nr)), len(set(nc))
print((r-a)*c + (c-b)*r - r + a - c + b + 1)

r, c = map(int, input().split())
a = [input() for i in range(r)]

count = 0
pos = []
z = 0
w = 0

for i in range(r):
    if 'S' not in a[i]:
        count += c
for i in range(r):
    if 'S' in a[i]:
        z = 0
        for j in range(c):
            if a[i][j] == '.':
                pos.append(z)
                z += 1
            else:
                z += 1
    if 'S' in a[i] and a[i].count('S') == len(a[i]):
        w = 1

    else:
        z = 0
e = 0
if w == 1:
    print(0)
else:
    if len(pos) == 0:
        print(count)
    else:
        e = [pos.count(i) for i in pos]
        if e.count(e[0]) == len(e):
            if 0 in pos:
                print(count + (max(pos)+1)*max(e))
            else:
                print(count + (max(pos)) * max(e))
        else:
            q = [pos.count(i) for i in pos]
            print(count + max(q)*2)

q = [pos.count(i) for i in pos]

r,c = map(int,input().split())
data = [list(input()) for i in range(r)]
print(data)
total=0
for i in range(r):
    if 'S' not in data[i]:
        total+=c
for j in range(c):
    for k in range(r):
        if data[k][j]=='S':
            break
    else:
        total=total+r-total//c
print(total)

r, c = map(int, input().split())
a = [input() for i in range(r)]

count = 0
pos = []
z = 0

for i in range(r):
    if 'S' not in a[i]:
        count += c
for i in range(r):
    if 'S' in a[i]:
        z = 0
        for j in range(c):
            if a[i][j] == '.':
                pos.append(z)
                z += 1
            else:
                z += 1
    else:
        z = 0

if len(pos) == 0:
    print(count)
else:
    c = [pos.count(i) for i in pos]
    p = c.count(max(c)) // max(c)
    print(count + 2 * p)

r,c=map(int,raw_input().split())

cake_cells=[]
cells_to_eat=0

for i in range(r):
    cells=[]
    cake=raw_input()
    for j in range(c):
        cells.append(cake[j])

    cake_cells.append(cells)

cake_cells_copy=cake_cells[:]
rows_eaten=[]

for i in range(r):
    if cake_cells[i].count('.')==c:
        cells_to_eat += c
        rows_eaten.append(i)

for i in range(c):
    count=0
    current=cake_cells[0][i]
    for j in range(1,r):
        if cake_cells[j][i]==current:
            count += 1
    if count==r-1:
        cells_to_eat += r-len(rows_eaten)

print cells_to_eat

def cakeminator(r,c,alist):
    collist=[]    # collist=list()
    for i in range(0,c):      # column
        isColEditable=True
        isCakeAvailable=False
        for j in range(0,r):  # row
            if alist[j][i]==".":
                isCakeAvailable=True
            elif alist[j][i]=="S":
                isColEditable=False

        if(isCakeAvailable and isColEditable):
            collist.append(i)
    rowlist=[]
    allRowsEdibleCount = 0
    for i in range(0,r):
        thisRowEdibleCount = 0
        isRowEditable=True
        isCakeAvailable=False
        for j in range(0,c):
            if alist[i][j]=="." and not j in collist:
                isCakeAvailable=True
            elif (alist[i][j]=="S"):
                isRowEditable=False
                thisRowEdibleCount+=1

        if(isCakeAvailable and isRowEditable):
            rowlist.append(i)
            allRowsEdibleCount += thisRowEdibleCount
    #print(collist)
    #print(rowlist)
    return len(collist)*r + allRowsEdibleCount

n,m=map(int,input().split())
blist=[]
for i in range(n):
    b=input()
    alist=list(b)
    blist.append(alist)
#print(blist)
print(cakeminator(n,m,blist))

"""
3 4
S...
....
..S.

"""

r, c = map(int, input().split())
tort = [input() for i in range(r)]
count = 0
s = 0
z = 0
column = []
q = 0
for i in range(r):
    if 'S' not in tort[i]:
        count += c
        z += 1

    elif 'S' in tort[i] and tort[i].count('S') == len(tort[i]):
        s = 1
if (count == 0 and s == 0) or (count > 0 and s == 1) or (count > 0 and s == 0):
    for i in range(c):
        for j in range(r):
            if tort[j][i] == '.':
                q += 1
        column.append(q)
        q = 0
    if count > 0:
        print(count + max(column)*column.count(max(column)) - column.count(max(column))*z)
    else:
        print(max(column)*column.count(max(column)))
else:
    print(0)

x,y = map(int,input().split())
z = []
b1 = 0
t = 0
for i in range(x):
	a = input()
	flag1 = 0
	for j in range(y):
		if a[j] == "S" and flag1 == 0:
			t = t + 1
			flag1 = 1
		elif j in z and a[j] == "S" :
			t = t + 1
			continue
		elif a[j] == "S":
			t = t + 1
			z.append(j)
print(x*y-t)

r, c = map(int, input().split())
tort = []
schet = 0
podschet_f = 0
podschet = 0
stolb=0
strok=0
for i in range(r):
    tort.append(list(str(input())))

for i in range(r):
    for j in range(c):
        if tort[i][j] != 'S':
            podschet_f += 1
        else:
            podschet_f = 0
    if podschet_f==c:
        schet += podschet_f
        podschet_f=0
        strok+=1
    else:
        podschet_f=0

for j in range(c):
    for i in range(r):
        if tort[i][j] != 'S':
            podschet += 1
        else:
            podschet = 0
    if podschet==r:
        schet += podschet
        podschet=0
        stolb+=1
    else:
        podschet=0

if strok>stolb and stolb>=1:
    print(schet-strok)
elif stolb>strok and strok>=1:
    print(schet-stolb)
elif r==strok and c==stolb:
    print(r*c)
else:
    print(schet)

import sys

def data():
    return sys.stdin.readline().strip()

def sp(): return map(int, data().split())
def l(): return list(sp())

temp=l()
r=temp[0]
c=temp[1]
t=[]
nr=[]
nc=[]
for i in range(r):
	t.append(list(data()))

for i in range(r):
    for j in range(c):
        if t[i][j]=='S':
            nr.append(i)
            nc.append(j)

common=(r-len(nr))*(c-len(nc))
eat=(r-len(nr))*c+(c-len(nc))*r-common
if eat<=0:
    print(0)
else:
    print(eat+1)

n, m = map(int, input().split())
a = []
[a.append(input()) for i in range(n)]
stroki = 0
stolb = 0
b = []
for j in range(m):
    bb = []
    for i in range(n):
        [bb.append(a[i][j])]
    b.append(' '.join(bb))
for ss in a:
    if 'S' not in ss:
        stroki += 1
for pp in b:
    if 'S' not in pp:
        stolb += 1
cc = []
for i in a:
    for j in i:
        cc.append(j)
        if 'S' not in cc:
            summa = n * m
        elif stroki != 0 and stolb != 0:
            summa = (stroki * m + stolb * n) - max(stroki, stolb)
        else:
            summa = (stroki * m + stolb * n)
print(summa)

def answer():
    a = input().split()
    a = [int(x) for x in a]
    i=0
    c=[]
    d1=[]
    while i<a[0]:
        d=list(input())
        j=0
        while j<len(d):
            if d[j]=="S":
                c.append(i)
                d1.append(j)
            j+=1
        i+=1
    ans = a[0]*a[1]-len(c)*len(d1)
    print(ans)
answer()

__author__ = 'abbas'
n = [int(x) for x in raw_input().split()]
r,c = n[0],n[1]
grid = [[0]*c]*r
count = r*c
for i in range(r):
    list = raw_input()
    for j in range(c):
        if(list[j] == 'S'):
            for x in range(r):
                if(grid[x][j] != 1):
                    grid[x][j] = 1
                    count -= 1
            for y in range(c):
                if(grid[i][y] != 1):
                    grid[i][y] = 1
                    count -= 1
print count

import sys

def input():    return sys.stdin.readline().strip()
def iinput():   return int(input())
def rinput():   return map(int, sys.stdin.readline().strip().split())
def get_list(): return list(map(int, sys.stdin.readline().strip().split()))

r,c=rinput()
a=[]
for i in range(r):
    s=list(input())
    a.append(s)
count=0
count1=0
for i in range(r):
    if(a[i]==['.']*c):
        count+=1

if(count==r):
    print(r*c)
elif(count==0):
    print(0)
else:
    i=0
    while(i<c):
        for j in range(r):
            if(a[j][i]=='S'):
                count1+=1
        i+=1

    l=(c-count1)*r -(c-count1)
    m=count*c
    print(l+m)

r,c = map(int,input().split())
dd =[]
for i in range(r):
    s = input()
    op=[]
    for ii in s:
        op.append(ii)
    dd.append(op)
pos =[]
for i in range(r):
    for j in range(c):
        if dd[i][j]=="S":
            t =(i,j)

            pos.append(t)
left = len(pos)*len(pos)
print((r*c)-left)

r,c=map(int,raw_input().split())
grid=[[0 for i in range(0,c)]for j in range(0,r)]
zuo=[]
cnt=0
for i in range(0,r):
    s=raw_input()
    for j in range(0,len(s)):
        if s[j]=='S':
            grid[i][j]=1
            cnt=cnt+1
            zuo.append([i,j])
for i in range(0,len(zuo)):
    for j in range(i,len(zuo)):
        if zuo[i][0]!=zuo[j][0] and zuo[i][1]!=zuo[j][1]:
            #grid[zuo[j][0]][zuo[i][1]]=1
            #grid[zuo[i][0]][zuo[j][1]]=1
            cnt=cnt+2
print r*c-cnt

x,y = map(int,input().split())
z = []
b1 = 0
t = 0
for i in range(x):
	a = input()
	flag1 = 0
	for j in range(y):
		# print(t)
		if a.count("S") > 0 and flag1 == 0:
			flag1 = 1
			t+=1
		if j in z:
			continue
		if a[j] == "S":
			t = t + 1
			z.append(j)
print(x*y-t)

r, c = map(int, input().split())
tort = []
schet = 0
podschet_f = 0
podschet = 0
stolb=0
strok=0
for i in range(r):
    tort.append(list(str(input())))

for i in range(r):
    for j in range(c):
        if tort[i][j] != 'S':
            podschet_f += 1
        else:
            podschet_f = 0
    if podschet_f==c:
        schet += podschet_f
        podschet_f=0
        strok+=1
    else:
        podschet_f=0

for j in range(c):
    for i in range(r):
        if tort[i][j] != 'S':
            podschet += 1
        else:
            podschet = 0
    if podschet==r:
        schet += podschet
        podschet=0
        stolb+=1
    else:
        podschet=0

if strok>stolb and stolb>=1:
    print(schet-strok)
elif stolb>strok and strok>=1:
    print(schet-stolb)
else:
    print(schet)

bawah,kanan  = list(map(int , input().split()))
kolom = []
baris = []
for z in range (bawah):
    a = input()
    listS = []
    for zz in range (len(a)):
        listS.append(a[zz])
    if "S" in listS:
        if listS.index("S") not in kolom:
            kolom.append(listS.index("S"))
        if z not in baris:
            baris.append(z)

kebawah = (kanan-len(kolom))*bawah
kesamping = (bawah-len(baris))*(kanan-(kanan-len(kolom)))
print(kebawah+kesamping)

r, c = map(int, input().split())
M = [input() for _ in range(r)]
for i in range(r):
    if 'S' not in M[i]:
        print((r - i) * c)
        break

r, c = map(int, input().split())
a = []
for i in range(r):
    a.append(input())
# print(a)
total_s_str = 0
total_s_column = 0
s_str = 0
s_column = 0
for i in range(r):
    for j in range(c):
        if a[i][j] != 'S':
            s_str += 1
            if s_str == c:
                total_s_str += c
        else:
            s_str = 0
# print(total_s_str)
for j in range(c):
    for i in range(r):
        if a[i][j] != 'S':
            s_column += 1
            if s_column == r:
                total_s_column += r
        else:
            s_column = 0
# print(total_s_column)
print((max(total_s_column, total_s_str) - min(total_s_column, total_s_str)) + max(total_s_column, total_s_str))

r,c=raw_input().split()
r=int(r)
c=int(c)
l=[]
l1=[]
l2=[]
for i in range(r):
    l=[x for x in raw_input()]
    l1.append(l)
for i in range(r):
    for j in range(c):
        if(l1[i][j]=='S'):
            l2.append(l1[i][j])
n=len(l2)
r=int(r)
c=int(c)
print (r*c)-(n*n)

r, c = map(int,input().split())
l=[]
for i in range(r):
	s = input()
	l.append(s)
a = []
for i in range(r):
	b = 0
	d=[]
	for j in range(c):
		if l[i][j] == "S":
			b=1
		else:
			d.append(j+1+i*c)
	if b == 0:
		for i in d:
			a.append(i)
for i in range(c):
	b= 0
	d= []
	for j in range(r):
		if l[j][i] == "S" :
			continue
		else:
			d.append(i+1+j*r)
	if b == 0:
		for i in d:
			a.append(i)
print(len(set(a)))

import sys

def input():    return sys.stdin.readline().strip()
def iinput():   return int(input())
def rinput():   return map(int, sys.stdin.readline().strip().split())
def get_list(): return list(map(int, sys.stdin.readline().strip().split()))

r,c=rinput()
a=[]
for i in range(r):
    s=list(input())
    a.append(s)
count=0
count1=0
for i in range(r):
    if(a[i]==['.']*c):
        count+=1

if(count==r):
    print(r*c)
else:
    i=0
    while(i<c):
        for j in range(r):
            if(a[j][i]=='S'):
                count1+=1
        i+=1

    l=(c-count1)*r -(c-count1)
    m=count*c
    print(m+l)

import sys
my_file = sys.stdin
#my_file = open("input.txt", "r")
line = [int(i) for i in my_file.readline().strip("\n").split()]
r, c = line[0], line[1]
table = my_file.read().split()
res = 0
for line in range(r):
    try:
        if "S" not in table[line]:
            res += len(table[line])
            del table[line]
            r -= 1
    except:
        pass
for char in range(c):
    for row in range(r):
        if table[row][char] == "S":
            break
    else:
        res += r
print(res)

r, c = map(int, raw_input().split())
a = []
k = 0
for i in range(r):
	s = str(raw_input())
	if not 'S' in s: k += c
	a.append(s)

for j in range(c):
	flag = True
	for i in range(r):
		if a[i][j] == 'S': flag = False
	if flag: k += r

print k

r,c=map(int, input().split())
x=set()
y=set()

for i in range(r):
    t = [k for k in list(input())]

    for j in range(c):
        if t[j] == 'S':
            x.add(j)
            y.add(j)

print(r*c-(len(x)*len(y)))

n,m=map(int,input().split())
y,z,z1,z2,z3=[],[],[],[],[]
k=0
for i in range(n):
    x=list(input())
    y.append(x)
for i in range(n):
    for j in range(m):
        if y[i][j]!="S":
            k+=1
        if k==m:
            z.append(k)
            k=0
for i in range(m):
    for j in range(n):
        if y[j][i]!="S":
            k+=1
        if k==n:
            z1.append(k)
            k=0
for i in range(len(z)//2):
    z2.append(z[i])
for i in range(len(z1)//2):
    z3.append(z1[i])
print((sum(z2)+sum(z3))-(len(z2)*len(z3)))

r, c = map(int, input().split())
p = [input() for i in range(r)]
pos = []
for i in p:
    pos.append(i.find('S'))
count = 0

for i in range(r):
    if 'S' not in p[i]:
        count += c
        p[i] = p[i].replace('.', '', c)

copy = pos[:]

if pos.count(-1) != len(pos) and pos.count(0) != len(pos):
    for i in range(pos.count(-1)):
        copy.remove(-1)
    count += (max(pos) - min(copy)) * (len(pos) - pos.count(-1))
    print(count)
elif pos.count(0) == len(pos):
    count += r * (c-1)
    print(count)
else:
    print(count)

n, m = map(int, input().split())
count = 0
r = [False]*n
c = [False]*m
for i in range(n):
    try:
        j = input().index('S')
        r[i] = True
        c[j] = True
    except:
        pass

print(r.count(False)*m + c.count(False)*n - (r.count(False)*c.count(False)))

'''input
2 2
..
..
'''
r, c = map(int, input().split())
nr, nc = [], []
for x in range(r):
	n = input()
	if "S" in n:
		nr.append(x)
		nc.append(n.index("S"))
a, b = len(set(nr)), len(set(nc))
print((r-a)*c + (c-b)*r - (r-a)*(c-b))

l=list(map(int,input().split()))
r=l[0]
c=l[1]
a=0
x=0
b=0
y=0
lst=list()
for i in range(r):
    s=input()
    lst.append(s)
for i in lst:
    a=0
    for j in i:
        if j=="s":
            a=1
            break
    if a==0:
       x=x+c
for i in range(c):
    b=0
    for j in range(r):
        if lst[j][i]=="s":
            b=1
            break
    if b==0:
        y=y+r
print(x+y-(x*y)//12)

# import sys
# sys.stdin=open("input.in",'r')
# sys.stdout=open("output1.out",'w')
n,m=map(int,input().split())
a=[]
c=0
for i in range(n):
	s=input()
	if 'S' in s:
		c+=1
		c+=s.count("S")
print(n*m-c)

import sys

def data():
    return sys.stdin.readline().strip()

def sp(): return map(int, data().split())
def l(): return list(sp())
def ssp(): return  data().split()
def sl(): return list(ssp())
temp=l()
r=temp[0]
c=temp[1]
t=[]
nr=[]
nc=[]
for i in range(r):
	t.append(list(data()))

print(t)
for i in range(r):
    for j in range(c):
        if t[i][j]=='S':
            nr.append(i)
            nc.append(j)
sum=''
common=(r-len(nr))*(c-len(nc))
for i in range(r):
	for j in range(c):
		if i not in nr and j not in nc:
			sum+=t[i][j]

print(len(sum)-common)

bawah,kanan  = list(map(int , input().split()))
kolom = []
baris = []
for z in range (bawah):
    a = input()
    listS = []
    for zz in range (len(a)):
        listS.append(a[zz])
    if "S" in listS:
        if listS.index("S") not in kolom:
            kolom.append(listS.index("S"))
        if z not in baris:
            baris.append(z)

kebawah = (kanan-len(kolom))*bawah
kesamping = (bawah-len(baris))*(kanan-(kanan-len(kolom)))
print(kebawah,kesamping)

n, p = map(int, input().split())
arr = []
for i in range(n):
    s = str(input())
    arr.append(s)

count = 0
#countExtra = 0
for i in range(n):
    counts = 0
    k = 0
    truth = True
    while k < p and truth == True:
        if arr[i][k:k+1] == ".":
            counts+=1
        if arr[i][k:k+1] == "S":
            truth = False
        k+=1
    if counts == p:
        count+=counts
        #countExtra+=1

for i in range(p):
    countss = 0
    kk = 0
    truthh = True
    while kk < n and truthh ==True:
        if arr[kk][i:i+1] == ".":
            countss+=1
        if arr[kk][i:i+1] == "S":
            truthh = False
        kk+=1
    if countss == n:
        count+=countss
        count-=1
print(count)

def solved(r,c,arr,evil):
    count = 0
    for i in range(r):
        if 'S' not in arr[i]:
            count += len(arr[i])
        for j in range(c):
            if i not in evil:
                count += 1
    print(count)
if __name__ == '__main__':
    r,c = map(int,input().split())
    arr = []
    evil = []
    for i in range(r):
        x = input()
        for j in x:
            if j == 'S':
                evil.append(x.index('S'))
        arr.append(x)
    solved(r,c,arr,evil)

def cake(n, m, grid):
    c = 0
    new = []
    for i in range(n):
        if 'S' not in grid[i]:
            c += m
            continue
        new.append(grid[i])

    for i in range(len(new)):
        for j in range(m):
            if new[i][j] == 'S':
                break
        c += len(new)

    return c

lst = [int(x) for x in input().split()]
n = lst[0]
m = lst[1]

grid = []
for i in range(n):
    s = input()
    temp = []
    temp.extend(s)
    grid.append(temp)

print(grid)

print(cake(n, m, grid))

n,m = map(int, input().split())
a = []
r = 0
c = 0
for i in range(n):
  temp = input()
  if 'S' in temp:
    r += 1
    c += 1

print(n*m - r*c)

n,m=map(int,input().split())
a=[]
b=[]
f=int(0)
count=int(0)
for i in range(n):
    b=input()
    a.append(b)
for i in range(n):
    if('S' not in a[i]):
        count=+m
for i in range(m):
    f=0
    for j in range(n):
        if('S' not in a[j][i]):
            f=1
        else:
            f=0
            break
    if(f==1):
       # print(i)
        count+=(n-(count//m))
print(count)

n,m=map(int,input().split())
s=""
for i in range(n):
    s=s+input()
#s=input()
x=s.count('S')
if x==m*n:
    print(0)
else:
    print(n*m-2*x)

(r, c) = map(int, raw_input().strip().split())

k = 0
g = 0
f = range(r)
for i in f:
    d = raw_input()
    if 'S' not in d:
        k = k + 1
    else:
        for j in range(len(d)):
            if d[j] == 'S':
                g = g+1
print r*c - (r-k)*g

r,c=map(int,input().split())
arr=[];row=[];col=[]
total=0
for i in range(r):
    arr.append(input())
for i in range(r):
    for j in range(c):
        if arr[i][j]=='S':
            row.append(i)
            col.append(j)
for i in range(r):
    if i not in row:
        total+=c
for j in range(c):
    if j not in col:
        total+=r-(total)//4
print(total)

r,c=map(int,input().split())
cake=[]
e=0
r1=0
st=[]
for i in range(r):
    s=input()
    cake.append(s)
for i in cake:
    if 'S' not in i:
        e+=c
        r1+=1
    else:
        j=i.find('S')
        st.append(j)
s1=list(set(st))
cl=c-len(s1)
e1=(r-r1)*cl
print(e+e1)

r, c = map(int, input().split())

def herota():
    net = {}

    for i in range(r):
        l = input()
        for j in range(c):
            net[i, j] = l[j]
            #print(l[j], end='')
        #print()

    #print(net)

    strawbery = [x for x in net if net[x]=='S']
    #print(strawbery)
    if len(strawbery) == 1:
        result = r * c - 1
        print(result)
        return
    if len(strawbery) == 0:
        result = r * c
        print(result)
        return

    hor = {x for x, y in strawbery}
    vert = {x for y, x in strawbery}
    #print(hor)
    #print(vert)
    a = ((c - len(hor)) *  r )
    b = ((r - len(vert)) * c )

    print(a+b-len(strawbery))

herota()

r, c = map(int, input().split())
a = []
for i in range(r):
    a.append(input())
# print(a)
total_s_str = 0
total_s_column = 0
for i in range(r):
    s_str = 0
    for j in range(c):
        if a[i][j] != 'S':
            s_str += 1
            if s_str == c:
                total_s_str += c
        else:
            s_str = 0
# print(total_s_str)
for j in range(c):
    s_column = 0
    for i in range(r):
        if a[i][j] != 'S':
            s_column += 1
            if s_column == r:
                total_s_column += r
        else:
            s_column = 0
# print(total_s_column)
if total_s_str == 0 or total_s_column == 0:
    print(max(total_s_column, total_s_str))
elif total_s_str == total_s_column:
    print(total_s_str // 2 + total_s_str)
else:
    print((max(total_s_column, total_s_str) - min(total_s_column, total_s_str)) + max(total_s_column, total_s_str))

l=list(map(int,input().split()))
r=l[0]
c=l[1]
a=0
x=0
b=0
y=0
lst=list()
for i in range(r):
    s=input()
    lst.append(s)
for i in lst:
    a=0
    for j in i:
        if j=="s":
            a=1
            break
    if a==0:
       x=x+c
for i in range(c):
    b=0
    for j in range(r):
        if lst[j][i]=="s":
            b=1
            break
    if b==0:
        y=y+r
print(x+y-(x*y)//(r*c))

r, c = map(int, input().split())
a = []
for i in range(r):
    a.append(input())
# print(a)
total_s_str = 0
total_s_column = 0
for i in range(r):
    s_str = 0
    for j in range(c):
        if a[i][j] != 'S':
            s_str += 1
            if s_str == c:
                total_s_str += c
        else:
            s_str = 0
# print(total_s_str)
for j in range(c):
    s_column = 0
    for i in range(r):
        if a[i][j] != 'S':
            s_column += 1
            if s_column == r:
                total_s_column += r
        else:
            s_column = 0
# print(total_s_column)
if total_s_str == 0:
    print(0)
else:
    print(total_s_str + (total_s_column - (total_s_str // c) * (total_s_column // r)))

r, c = map(int, input().split())
M = [input() for _ in range(r)]
for i in range(r):
    if 'S' not in M[i]:
        print((r - i) * c)
        break

r,c=map(int,input().split())
a=[]
rapple=0
capple=0
for i in range(r):
    n=input()
    flag=False
    for j in n:
        if j=='S':
            capple+=1
            flag=True
    if (flag):
        rapple+=1
    a.append(list(n))
print (r*c-(rapple*capple))

import sys

inf = float("inf")
# sys.setrecursionlimit(10000000)

# abc='abcdefghijklmnopqrstuvwxyz'
# abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod, MOD = 1000000007, 998244353
# vow=['a','e','i','o','u']
# dx,dy=[-1,1,0,0],[0,0,1,-1]

# import random
# from collections import deque, Counter, OrderedDict,defaultdict
# from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
# from math import ceil,floor,log,sqrt,factorial
# from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right

def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

n,m = get_ints()
mat = []
for i in range(n):
    mat.append(list(input()))

# print(mat)
visited = [[0 for i in range(m)] for j in range(n)]
for i in range(n):
    for j in range(m):
        flag = 0
        for k in range(n):
            if mat[k][j]=='S':
                flag = 1
        for k in range(m):
            if mat[i][k]=='S':
                flag = 1
        if flag==1:
            continue
        else:
            for k in range(n):
                visited[k][j] = 1
            for k in range(m):
                visited[i][k] = 1
ans = 0
for i in visited:
    ans+=i.count(1)
print(ans)

r, c = map(int, input().split())

net = {}

for i in range(r):
    l = input()
    for j in range(c):
        net[i, j] = l[j]
        print(l[j], end='')
    #print()

#print(net)

strawbery = [x for x in net if net[x]=='S']
#print(strawbery)

hor = {x for x, y in strawbery}
vert = {x for y, x in strawbery}
#print(hor)
#print(vert)
a = ((c - len(hor)) *  r )
b = ((r - len(vert)) * c )
print(a+b-len(strawbery))

from math import comb
def solve():
    n,m=list(map(int,input().split()))
    l=list()
    for i in range(n):
        l.append(input())
    flag,row,col=1,0,0
    for i in range(n):
        for j in range(m):
            if(l[i][j]=="S"):
                flag=0
        if(flag):
            row+=1
        flag=1
    flag=1
    for i in range(m):
        for j in range(n):
            if(l[j][i]=="S"):
                flag=0
        if(flag):
            col+=1
        flag=1
    print(row*m+col*n-comb(max(row,col),min(row,col)))
t=1
for _ in range(t):solve()

r, c = map(int,input().split(' '))
count = 0
A = []
x = 0

for i in range(r):
    n = list(input())

    if 'S' not in n:
        x += 1

    A.append(n)

y = []
p = 0

for i in range(c):
    for j in range(r):
        y.append(A[j][i])

    if 'S' not in y:
        p += 1

    y = []

count = r*c - (r-x)*c-p

print(count)

r,c=map(int,input().strip().split())
l=[]
R=0
C=0
z=0
C1=set()
for i in range(r):
    l.append(input())
    k=l[i].find('S',0)
    if  k== -1:
        z+=1
    else:
        R+=1
        C1.add(k)
C=len(C1)
print(r*c-R*C)

n, m = map(int, input().split())
a = []
for i in range(n):
    b = list(input())
    a.append(b)

s = 0
z = 0
for i in range(n):
    if "S" not in a[i]:
        z = +1
        s += len(a[i])

for i in range(m):
    d = []
    for j in range(n):
        d.append(a[j][i])
    if "S" not in d:
        s += len(d)-z

print(s)

r, c = map(int,input().split())

j = []

for i in range(r):
  o = input().find('S')

  if o != -1:
    j.append(o)

if len(j) == 2 :
  if j[0] == j[1] :
    print(r*c-2)
  else :
    print(r*c-4)
else :
  print(r*c-4)

from __future__ import print_function
import sys

def main():
	vstup=(sys.stdin.readline()).split(" ")
	r=int(vstup[0])
	c=int(vstup[1])
	chocolate=[]

	for i in range(r):
		chocolate.append(list(sys.stdin.readline()))
	count=c*r

	for i in range(r):
		for j in range(c):
			if chocolate[i][j]=='S':
				count-=c
				break
	s=count/c
	print(count, s)

	for j in range(c):
		for i in range(r):
			if chocolate[i][j]=='S':
				break
			if i==r-1 and chocolate[r-1][j]!='S':
				count+=r-s
	print(count)

if __name__ == "__main__":
	main()

r,c=map(int,input().split())
a=[]
nr=0
nc=0
for i in range(r):
	p=list(input())
	a.append(p)
	if "S" in p:
		nr+=1
		nc+=1
print((r-nr)*c+(c-nc)*r-max(r-nr,c-nc))

import sys

def data():
    return sys.stdin.readline().strip()

def sp(): return map(int, data().split())
def l(): return list(sp())

temp=l()
r=temp[0]
c=temp[1]
t=[]
nr=[]
nc=[]
for i in range(r):
	t.append(list(data()))
for i in range(r):
    for j in range(c):
        if t[i][j]=='S':
            nr.append(i)
            nc.append(j)

common=(r-len(nr))+(c-len(nc))
eat=(r-len(nr))*c+(c-len(nc))*r-common
if eat<=0:
    print(0)
else:
    print(eat)

r,c=map(int,input().split())
store=[]
for i in range(r):
    s=input()
    for j in range(c):
        if(s[j]=='S'):
            store.append((i,j))
if(store==[]):
    print(r*c)
else:
    store = list(zip(*store))
    print(r * c - len(store[0]) * len(store[1]))

r,c = map(int,raw_input().split())
ls = []
for i in range(r):
    temp = raw_input()
    ps = []
    for j in range(c):
        ps.append(temp[j])
    ls.append(ps)

sum = r*c

p = 0
q = 0

for i in range(r):
    check = False
    for j in range(c):
        if ls[i][j]=='S':
            check = True
            q+=1
    if check == True:
        p +=1

print(sum-p*q)

l=list(map(int,input().split()))
r=l[0]
c=l[1]
a=0
x=0
b=0
y=0
lst=list()
for i in range(r):
    s=input()
    lst.append(s)
for i in lst:
    a=0
    for j in i:
        if j=="s":
            a=1
            break
    if a==0:
       x=x+c
for i in range(c):
    b=0
    for j in range(r):
        if lst[j][i]=="s":
            b=1
            break
    if b==0:
        y=y+r
print(x+y-(x*y)//12)

__author__ = 'abbas'
n = [int(x) for x in raw_input().split()]
r,c = n[0],n[1]
grid = [[0 for x in range(c)] for y in range(r)]
count = r*c
for i in range(r):
    list = raw_input()
    for j in range(c):
        if list[j] == 'S':
            for x in range(r):
                if grid[x][j] != 1:
                    grid[x][j] = 1
                    count -= 1
            for y in range(c):
                if grid[i][y] != 1:
                    grid[i][y] = 1
                    count -= 1
print count

r_c=raw_input()
r_c=r_c.split(' ')
r=int(r_c[0])
c=int(r_c[1])
minus=0
result=0
torts=[]
for i in range(r):
    tort=raw_input()
    torts.append(tort)
for i in torts:
    if 'S' in i:
        minus+=1
        result+=c
for i in range(r):
    curr_result=0
    for j in range(c):
        if torts[i][j]=='S':
            break
        curr_result+=1
    if curr_result==r:
        result+=c-minus
print result

r,c=map(int,input().split())
l=[]
for i in range(r):
	w=list(input())
	l.append(w)
m=[]
for i in range(r):
	for j in range(c):
		if l[i][j]!="S":
			t=[i,j]
			m.append(t)
a=[]
q=[]
f=max(c,r)
for i in range(f):
	count=0
	plus=0
	for j in range(len(m)):
		if m[j][0]==i:
			count+=1
		if m[j][1]==i:
			plus+=1
	a.append(count)
	q.append(plus)
y=a.count(c)
u=q.count(r)
o=(y*c)+(u*r)-max(y,u)
print(o)

r,c=map(int,input().split())
mm=r*c
mat=[]
for i in range(r):
    s=input()
    mat.append(s)
ans=0
rr=0;cc=0;s=0
for i in range(r):
    for j in range(c):
        if mat[i][j]=='S':
            rr+=1
            break
for i in range(c):
    for j in range(r):
        if mat[j][i]=='S':
            cc+=1
            break
for i in range(r):
    for j in range(c):
        if mat[i][j]=='S':
            s+=1
r-=rr
c-=cc
if rr==0 or cc==0:
    print(mm-s)
else:
    print(mm-r*c-s)

#!/usr/bin/python

r,c = map(int,raw_input().split())
count = 0
cake = []

for i in range(r):
        cake.append(raw_input())

indexr = [i for i in range(r) for j in cake[i] if j == 'S']
count = (r - len(indexr))* c

indexc = [i for i in range(c) for j in range(r) if cake[j][i] == 'S']
count = count + ((c - len(indexc))*r)

count = count - (r-len(indexr)) * (c - len(indexc))
if count < 0:
        print "0"
else:
        print count

r,c = map(int,input().split())

count = 0
for i in range(r) :
    s = input()
    count += s.count('S')
out = (r*c) - (2*count)
if out < 0 :
    out = 0
print(out)

l=lambda :map(int,input().split())
r,c=l()
k=[input() for _ in " "*r]
n=0
p,q=r,c
for i in range(p):
    a=k[i].count('.')
    if a==c:
        r-=1
        n+=c
t=list(zip(*k))
for i in range(q):
    a = t[i].count('.')
    if a==r:
        n+=r
print(n)

r, c = map(int, input().split())

def herota():
    net = {}

    for i in range(r):
        l = input()
        for j in range(c):
            net[i, j] = l[j]
            #print(l[j], end='')
        #print()

    #print(net)

    strawbery = [x for x in net if net[x]=='S']
    #print(strawbery)
    if len(strawbery) == 1:
        result = r * c - 1
    if len(strawbery) == 0:
        result = r * c

    hor = {x for x, y in strawbery}
    vert = {x for y, x in strawbery}
    #print(hor)
    #print(vert)
    a = ((c - len(hor)) *  r )
    b = ((r - len(vert)) * c )

    print(a+b-len(strawbery))

herota()

r, c = map(int,input().split())

j = []

for i in range(r):
  o = input().find('S')

  if o != -1:
    j.append(o)

if len(j) == 2 :
  if j[0] == j[1] :
    print(r*c-2)
  else :
    print(r*c-4)
elif len(j) == 0 :
  print(r*c)
else :
  print(r*c-4)

r,c=list(map(int,input().split()))
e,l=[],[]
count=0
for i in range(r):
	l=list(input())
	if "S" not in l:
		count+=1
	else:
		e.append(l.index("S"))
e=set(e)
print((count*c)+(((c-len(e))*r)-((c-len(e))*count)))

r,c=map(int,input().split())
mm=r*c
mat=[]
for i in range(r):
    s=input()
    mat.append(s)
ans=0
rr=0;cc=0;s=0
for i in range(r):
    for j in range(c):
        if mat[i][j]=='S':
            rr+=1
            break
for i in range(c):
    for j in range(r):
        if mat[j][i]=='S':
            cc+=1
            break
for i in range(r):
    for j in range(c):
        if mat[i][j]=='S':
            s+=1
r-=rr
c-=cc
print(rr,cc)
if s==0:
    print(r*c)
else:
    print(mm-rr*cc)

r,c=map(int,input().split())
store=[]
for i in range(r):
    s=input()
    for j in range(c):
        if(s[j]=='S'):
            store.append((i,j))
if(store==[]):
    print(r*c)
else:
    store = list(zip(*store))
    k=r * c - len(store[0]) * len(store[1])
    print([k,0][k<0])

r, c = map(int, input().split())
a = []
for i in range(r):
    a.append(input())
s = 0
for i in range(r):
    for j in range(c):
        if a[i][j] == 'S':
            s += 1
print((2 * (r * c) - (s * r + s * c)) - s)

r, c = map(int, input().split())

net = {}

for i in range(r):
    l = input()
    for j in range(c):
        net[i, j] = l[j]
        #print(l[j], end='')
    #print()

#print(net)

strawbery = [x for x in net if net[x]=='S']
#print(strawbery)

hor = {x for x, y in strawbery}
vert = {x for y, x in strawbery}
#print(hor)
#print(vert)
a = ((c - len(hor)) *  r )
b = ((r - len(vert)) * c )
print(a+b-len(strawbery))

r,c=map(int,input().split())
A,B=[],[]
for i in range(r):
    R=list(input())
    while('S'in R):
        I=R.index('S')
        B+=[I]
        A+=[i]
        R[I]='.'
print((r*c)-sum(set(A))*sum(set(B)))

n,m = map(int,input().split())
row,col = 0,0
l=[]
for i in range(n):
	l.append(input())

for i in range(n):
	for j in range(m):
		if l[i][j] == 'S':
			# print('i','j',i,j)
			row+=1

for j in range(m):
	for i in range(n):
		if l[i][j] == 'S':
			col+=1

print(n*m - row*col)

import sys
my_file = sys.stdin
#my_file = open("input.txt", "r")
line = [int(i) for i in my_file.readline().strip("\n").split()]
r, c = line[0], line[1]
table = my_file.read().split()
res = 0
for line in table:
    if "S" not in line:
        res += len(line)
        table.remove(line)
        r -= 1
for row in range(r):
    for col in range(c):
        for row1 in range(r):
            if "S" in table[row1][col]:
                break
        else:
            res += len(table[row][col])
print(res)

# import sys
# sys.stdin=open("input.in",'r')
# sys.stdout=open("output1.out",'w')
n,m=map(int,input().split())
a=[]
c=0
for i in range(n):
	s=input()
	if 'S' in s:
		c+=1
		c+=s.count("S")
print(max(n*m-c,0))