You are given a rectangular cake, represented as an r × c grid. Each cell either has an evil strawberry, or is empty. For example, a 3 × 4 cake may look as follows: [Image] 

The cakeminator is going to eat the cake! Each time he eats, he chooses a row or a column that does not contain any evil strawberries and contains at least one cake cell that has not been eaten before, and eats all the cake cells there. He may decide to eat any number of times.

Please output the maximum number of cake cells that the cakeminator can eat.


-----Input-----

The first line contains two integers r and c (2 ≤ r, c ≤ 10), denoting the number of rows and the number of columns of the cake. The next r lines each contains c characters — the j-th character of the i-th line denotes the content of the cell at row i and column j, and is either one of these:   '.' character denotes a cake cell with no evil strawberry;  'S' character denotes a cake cell with an evil strawberry. 


-----Output-----

Output the maximum number of cake cells that the cakeminator can eat.


-----Examples-----
Input
3 4
S...
....
..S.

Output
8



-----Note-----

For the first example, one possible way to eat the maximum number of cake cells is as follows (perform 3 eats). [Image]  [Image]  [Image]

Difficulty: EASY

Solutions:
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
(r, c) = map(int, input().split())
l = []
for _ in range(r):
	l.append(input())
print(solve(l))


(a, b) = list(map(int, input().split()))
u = 0
t = []
for i in range(a):
	t.append(list(input()))
for j in t:
	if 'S' in j:
		pass
	else:
		for k in range(len(j)):
			j[k] = 'a'
			u += 1
for m in range(b):
	y = []
	for l in range(a):
		y.append(t[l][m])
	if 'S' not in y:
		for e in range(len(y)):
			if y[e] == '.':
				u += 1
				y[e] = 'a'
print(u)


(r, c) = [int(s) for s in input().split(' ')]
rows = []
r_cnt = 0
c_cnt = 0
for i in range(r):
	row = input()
	if row == '.' * c:
		r_cnt += 1
	rows.append(row)
for j in range(c):
	col = [rows[k][j] for k in range(r)]
	if col == ['.'] * r:
		c_cnt += 1
print(r_cnt * c + c_cnt * (r - r_cnt))


(x, y) = map(int, input().split())
grid = []
for i in range(x):
	line = list(input())
	grid.append(line)
C = 0
for i in range(x):
	if 'S' not in grid[i]:
		C += y
		grid[i] = [1] * y
for i in range(y):
	temp = x
	for j in range(x):
		if grid[j][i] == 'S':
			break
		elif grid[j][i] == 1:
			temp -= 1
	else:
		C += temp
print(C)


(r, c) = [int(i) for i in input().split(' ')]
ls = list()
for i in range(r):
	ls_ = [-(c + r) if s == 'S' else 1 for s in input()]
	ls.append(ls_)
result = 0
for i in range(r):
	sum_ = sum([s_ for s_ in ls[i]])
	if sum_ < 0:
		continue
	result += sum_
	for j in range(c):
		if ls[i][j] >= 0:
			ls[i][j] = 0
for i in range(c):
	sum_ = sum([ls[s_][i] for s_ in range(r)])
	if sum_ < 0:
		continue
	result += sum_
	for j in range(r):
		if ls[j][i] >= 0:
			ls[j][i] = 0
print(result)


(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 - stolb * strok)
elif stolb >= strok and strok >= 1:
	print(schet - stolb * strok)
elif r == strok and c == stolb:
	print(r * c)
else:
	print(schet)


(n, m) = map(int, input().split())
c = []
a = [0] * n
b = [0] * m
for i in range(n):
	c.append(input())
for i in range(n):
	for j in range(m):
		if c[i][j] == '.':
			b[j] += 1
			a[i] += 1
d = m * a.count(m)
d += n * b.count(n)
d = d - a.count(m) * b.count(n)
print(d)


(r, c) = map(int, input().strip().split())
l = []
R = 0
C = 0
for i in range(r):
	l.append(input())
	if l[i].find('S', 0) == -1:
		R += 1
for i in range(c):
	t = []
	for j in range(r):
		t.append(l[j][i])
	T = ''.join(t)
	if T.find('S', 0) == -1:
		C += 1
print(r * c - (r - R) * (c - C))


I = lambda : map(int, input().split())
(n, m) = I()
cakearray = [input() for i in range(n)]
rowcells = len([0 for s in cakearray if 'S' not in s])
collcells = 0
for i in range(m):
	temp = 0
	for j in range(n):
		if cakearray[j][i] == 'S':
			temp = 0
			break
		else:
			temp = 1
	collcells += temp
print(rowcells * m + (collcells * n - rowcells * collcells))


z = list(map(int, input().split()))
n = []
m = []
for i in range(z[0]):
	x = list(input().split())
	for u in x:
		n.append(u)
c = 0
for i in range(z[1]):
	d = 0
	for o in n:
		m.append(o[c])
		d = d + 1
		if d == z[0]:
			c = c + 1
a = []
for i in n:
	s = 0
	for o in i:
		s = s + 1
		if o == 'S':
			s = 0
			break
		elif s == z[1]:
			a.append(s)
v = 0
b = 0
l = []
for i in m:
	v = v + 1
	b = b + 1
	if i == 'S':
		b = 0
	if b == z[0]:
		if a != []:
			l.append(b - len(a))
		else:
			l.append(b)
	if v == z[0]:
		b = 0
		v = 0
p = l + a
qw = 0
for i in p:
	qw = qw + i
print(qw)


(r, c) = map(int, input().split())
matrix = []
res = 0
for i in range(r):
	matrix.append(input())
for i in range(r):
	for j in range(c):
		f = True
		g = True
		if matrix[i][j] == '.':
			for k in range(c):
				if matrix[i][k] == 'S':
					f = False
					break
			for l in range(r):
				if matrix[l][j] == 'S':
					g = False
					break
			if f or g:
				res += 1
print(res)


from pprint import pprint
(r, c) = map(int, input().split())
vals = []
for _ in range(r):
	vals.append(input())
res = 0
for i in range(r):
	if 'S' not in vals[i]:
		res += vals[i].count('.')
		vals[i] = '*' * len(vals[i])
vals_rotated = list(zip(*vals[::-1]))
for i in range(c):
	if 'S' not in vals_rotated[i]:
		res += vals_rotated[i].count('.')
print(res)


(r, t) = map(int, input().split())
w = []
d = 0
l = 0
h = 0
m = [0] * 100
for i in range(r):
	s = input()
	c = 0
	f = 0
	for j in range(len(s)):
		w.insert(j, s[j])
		if w[j] == '.' and f != 1:
			c = c + 1
		elif w[j] == 'S':
			c = 0
			f = 1
			if m[j] != -1:
				d = d + 1
				m[j] = -1
	l = l + c
	if c != 0:
		h = h + 1
print(l + (t - d) * (r - h))


(r, c) = map(int, input().split())
s_r = set()
s_c = set()
t = 0
t_r = 0
for i in range(r):
	s = input()
	for j in range(c):
		if s[j] == 'S':
			if i not in s_r:
				s_r.add(i)
				t_r += 1
			s_c.add(j)
for i in range(r):
	if i not in s_r:
		t += c
for j in range(c):
	if j not in s_c:
		t += t_r
print(t)


(r, c) = input().split(' ')
r = int(r)
c = int(c)
count = 0
matrix = [[None] * c] * r
for x in range(r):
	matrix[x] = list(input())
for x in range(r):
	if 'S' in matrix[x]:
		pass
	else:
		for y in range(len(matrix[x])):
			if matrix[x][y] is not None:
				count += 1
				matrix[x][y] = None
for y in range(c):
	running = 0
	for x in range(r):
		if matrix[x][y] == 'S':
			running = 0
			break
		elif matrix[x][y] is not None:
			running += 1
			matrix[x][y] = None
	count += running
print(count)


(r, c) = map(int, input().split())
R = [0] * r
C = [0] * c
for i in range(r):
	s = input()
	if s.count('S') > 0:
		R[i] = 1
	for j in range(c):
		if s[j] == 'S':
			C[j] = 1
print(c * r - (r - R.count(0)) * (c - C.count(0)))


def solve(x, y, a, n, m):
	for j in range(m):
		if a[x][j] == 'S':
			for i in range(n):
				if a[i][y] == 'S':
					return 0
	return 1
(n, m) = map(int, input().split())
a = []
for z in range(n):
	a.append(list(input()))
cake = 0
for i in range(n):
	for j in range(m):
		cake += solve(i, j, a, n, m)
print(cake)


def main():
	(r, c) = input().split(' ')
	cake = []
	eat = 0
	eliminate = []
	for i in range(int(r)):
		row = input()
		row = list(row)
		cake.append(row)
	for i in range(int(r)):
		evilstrwbr = 0
		for j in range(int(c)):
			if cake[i][j] == 'S':
				evilstrwbr += 1
		if evilstrwbr == 0:
			eliminate.append(i)
	while len(eliminate) != 0:
		indice = eliminate.pop()
		del cake[indice]
		eat = eat + int(c)
	if not cake:
		print(eat)
	else:
		for i in range(len(cake[0])):
			evilstrwbr = 0
			for j in range(len(cake)):
				if cake[j][i] == 'S':
					evilstrwbr += 1
			if evilstrwbr == 0:
				eliminate.append(i)
		while len(eliminate) != 0:
			indice = eliminate.pop()
			for i in range(len(cake)):
				del cake[i][indice]
			eat = eat + len(cake)
		print(eat)
main()


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


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
(n, m) = mp()
ml = [inp() for i in range(n)]
tn = n
ans = 0
for i in range(n):
	if 'S' not in ml[i]:
		tn -= 1
		ans += m
for i in range(m):
	c = 0
	for j in range(n):
		if ml[j][i] == 'S':
			c += 1
	if c == 0:
		ans += tn
print(ans)


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


from collections import deque, Counter
import array
from itertools import combinations, permutations
from math import sqrt
import unittest

def read_int():
	return int(input().strip())

def read_int_array():
	return [int(i) for i in input().strip().split(' ')]
(rows, cols) = read_int_array()
field = [input().strip() for _ in range(rows)]
rows_taken = 0
for r in range(rows):
	rows_taken += 1 if 'S' not in field[r] else 0
count = rows_taken * cols
for c in range(cols):
	count += rows - rows_taken if 'S' not in (field[r][c] for r in range(rows)) else 0
print(count)


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


(r, c) = list(map(int, input().strip().split(' ')))
g = []
for i in range(0, r):
	s = list(input().strip())
	g.append(s)
t = g[:]
for i in range(0, r):
	bj = True
	for j in range(0, c):
		if g[i][j] == 'S':
			bj = False
	if bj:
		for k in range(0, c):
			t[i][k] = '0'
for i in range(0, c):
	bj = True
	for j in range(0, r):
		if g[j][i] == 'S':
			bj = False
	if bj:
		for k in range(0, r):
			t[k][i] = '0'
s = 0
for i in range(0, r):
	for j in range(0, c):
		if t[i][j] == '0':
			s += 1
print(str(s))


def run():
	(r, c) = [int(_) for _ in input().split()]
	lines = [input() for i in range(r)]
	num_rows = [1 if 'S' in i else 0 for i in lines]
	import math
	num_rows = sum(num_rows)
	num_rows = sum([0 if 'S' in i else 1 for i in lines])
	num_cols = 0
	for j in range(c):
		found = False
		for i in range(r):
			if lines[i][j] == 'S':
				found = True
		if not found:
			num_cols += 1
	return num_cols * r - num_rows * num_cols + num_rows * c
print(run())


(r, c) = map(int, input().split())
row = list(range(r))
col = list(range(c))
for i in range(r):
	cl = input()
	for j in range(c):
		if cl[j] == 'S':
			if i in row:
				row.remove(i)
			if j in col:
				col.remove(j)
ans = len(row) * c + len(col) * r - len(row) * len(col)
print(ans)


(r, c) = map(int, input().split())
row = [0] * r
col = [0] * c
arr = []
for i in range(r):
	arr.append(input())
for i in range(r):
	for j in range(c):
		if arr[i][j] == 'S':
			col[j] += 1
			row[i] += 1
ccol = 0
crow = 0
for x in row:
	if x == 0:
		crow += 1
for x in col:
	if x == 0:
		ccol += 1
print(c * crow + r * ccol - ccol * crow)


(row, col) = [int(x) for x in input().split()]
cake = []
for _ in range(row):
	cake.append([x for x in input()])
r = [s for s in cake if s.count('S')]
v = [s for s in zip(*cake) if s.count('S')]
print(row * col - len(r) * len(v))


x = [int(n) for n in input().split()]
l = 0
s = []
for k in range(x[0]):
	s.append([n for n in input()])
iu = 0
for n in range(len(s)):
	if s[n].count('S') == 0:
		l += len(s[n])
		iu = 1
		for k in range(len(s[n])):
			s[n][k] = 'a'
	else:
		iu = 0
		continue
pp = []
for n in range(len(s[0])):
	for k in range(len(s)):
		if s[k][n] == 'S':
			pp.append(n)
			break
		else:
			continue
for n in range(len(s[0])):
	if pp.count(n) == 0:
		for k in range(len(s)):
			if s[k][n] != 'a':
				l += 1
	else:
		continue
print(l)


Coordinat = input().split()
Clst = []
Rlst = []
for x in range(int(Coordinat[0])):
	for (index, y) in enumerate(input()):
		if 'S' == y:
			Clst.append(index)
			Rlst.append(x)
print(int(Coordinat[0]) * int(Coordinat[1]) - len(set(Clst)) * len(set(Rlst)))


(a, b) = map(int, input().split())
list1 = [input() for i in range(a)]
print(a * b - len([1 for i in list1 if i.count('S')]) * len([1 for j in zip(*list1) if j.count('S')]))


(r, c) = map(int, input().split())
l = []
for i in range(r):
	s = str(input())
	a = list(s)
	l.append(s)
ans = 0
ls = ['*' for i in range(c)]
for i in range(r):
	if 'S' not in l[i]:
		ans += c
		l[i] = ls
for i in range(c):
	b = []
	for j in range(r):
		b.append(l[j][i])
	if 'S' not in b:
		ans += b.count('.')
print(ans)


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)


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


(r, c) = str(input()).split()
r = int(r)
c = int(c)
face = list()
for i in range(r):
	line = str(input())
	temp_list = list()
	for j in range(c):
		if line[j] == 'S':
			temp_list.append(1)
		else:
			temp_list.append(0)
	face.append(temp_list)
value = 0
for i in range(r):
	flag = True
	for j in range(c):
		if face[i][j] > 0:
			flag = False
			break
	if flag:
		value += c
		for j in range(c):
			face[i][j] = -1
for j in range(c):
	num = 0
	flag = True
	for i in range(r):
		if face[i][j] > 0:
			flag = False
			break
		if face[i][j] == 0:
			num += 1
	if flag:
		value += num
print(value)


def inpNum():
	return int(input())

def inpNums():
	return map(int, input().split())

def inpList():
	return list(map(int, input().split()))

def inpStrMatrix(rows):
	return [list(input()) for _ in range(rows)]
(r, c) = inpNums()
mat = inpStrMatrix(r)
rs = set()
cs = set()
for _r in range(r):
	for _c in range(c):
		if mat[_r][_c] == 'S':
			rs.add(_r)
			cs.add(_c)
t = 0
left_rows = r - len(rs)
left_cols = c - len(cs)
t += left_rows * c
t += left_cols * r - left_rows * left_cols
print(t)


(r, c) = map(int, input().split())
a = []
b = []
for i in range(r):
	a.append(input())
for i in range(r):
	if 'S' not in a[i]:
		a[i] = 'X' * c
for j in range(c):
	c = []
	for i in range(r):
		c.append(a[i][j])
	b.append(c)
for i in range(len(b)):
	if 'S' not in b[i]:
		for j in range(r):
			b[i][j] = 'X'
k = 0
for i in range(len(b)):
	for j in range(r):
		if b[i][j] == 'X':
			k += 1
print(k)


(rows, columns) = map(int, input().split())
cake = []
ans = 0
for i in range(rows):
	cake.append(input())
while columns * '.' in cake:
	ans += columns
	cake.remove(columns * '.')
	rows -= 1
cake = [''.join(a) for a in zip(*cake)]
while rows * '.' in cake:
	ans += rows
	cake.remove(rows * '.')
print(ans)


import sys

class Cake:

	def __init__(self, row, col, ca):
		self.r = row
		self.c = col
		self.cell = ca

	def show(self):
		for i in range(self.r):
			print(self.cell[i])

	def calCell(self):
		countRow = 0
		for x in self.cell:
			if x == '.' * self.c:
				countRow += 1
		countColCell = 0
		for i in range(self.c):
			isS = False
			for j in self.cell:
				if j[i] != '.':
					isS = True
			if isS is False:
				countColCell += self.r - countRow
		return countColCell + countRow * self.c

def main():
	(r, c) = [int(x) for x in sys.stdin.readline().split()]
	cake = []
	for x in range(r):
		cake.append(sys.stdin.readline().strip())
	board = Cake(r, c, cake)
	print(board.calCell())
main()


(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) * max(stroki, stolb)
elif stroki != 0 or stolb != 0:
	summa = stroki * m + stolb * n - max(stroki, stolb) * min(stroki, stolb)
print(summa)


(a, b) = list(map(int, input().split()))
m = []
for i in range(a):
	m.append(list(input()))
c = 0
for i in range(a):
	for j in range(b):
		if 'S' not in m[i]:
			c += 1
			m[i][j] = '0'
		else:
			break
im = []
im += [0] * b
for i in range(b):
	im[i] = [0] * a
	for j in range(a):
		im[i][j] = m[j][i]
for i in range(b):
	for j in range(a):
		if 'S' not in im[i]:
			if '.' in im[i][j]:
				c += 1
				im[i][j] = '0'
		else:
			break
print(c)


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


(r_val, c_val) = list(map(int, input().split()))
row_es = [0] * r_val
col_es = [0] * c_val
data = list()
eat_or_not = list()
for row in range(r_val):
	data.append(input())
	eat_or_not.append([0] * c_val)
for row in range(r_val):
	for col in range(c_val):
		if data[row][col] == 'S':
			row_es[row] = 1
			col_es[col] = 1
count = 0
for row in range(r_val):
	if row_es[row] == 0:
		for col in range(c_val):
			if eat_or_not[row][col] == 0:
				eat_or_not[row][col] = 1
				count += 1
for col in range(c_val):
	if col_es[col] == 0:
		for row in range(r_val):
			if eat_or_not[row][col] == 0:
				eat_or_not[row][col] = 1
				count += 1
print(count)


(r, c) = (int(x) for x in input().split())
(ck, rs, cs) = ([], set(), set())
val = 0

def eat(i, j):
	global val
	if ck[i][j] == '.':
		ck[i][j] = 'X'
		val += 1
for i in range(r):
	ck.append(list(input()))
	for (j, ce) in enumerate(ck[i]):
		if ce == 'S':
			rs.add(i)
			cs.add(j)
for i in range(r):
	if i not in rs:
		for j in range(c):
			eat(i, j)
for j in range(c):
	if j not in cs:
		for i in range(r):
			eat(i, j)
print(val)


line = [int(i) for i in str(input()).split()]
rows = line[0]
colmuns = []
for row in range(line[0]):
	l = str(input())
	if 'S' in l:
		rows -= 1
		for i in range(line[1]):
			if l[i] == 'S' and (not i in colmuns):
				colmuns.append(i)
print(rows * line[1] + (line[1] - len(colmuns)) * line[0] - rows * (line[1] - len(colmuns)))


(r, c) = map(int, input().split())
r_set = set()
c_set = set()
for i in range(r):
	s = input()
	for j in range(c):
		if s[j] == 'S':
			r_set.add(i)
			c_set.add(j)
print((r - len(r_set)) * c + (c - len(c_set)) * len(r_set))


(r, c) = map(int, input().split())
list1 = []
list2 = []
for i in range(r):
	k = list(map(str, input().split()))
	list1.append(k)
for i in range(len(list1)):
	list2.append([])
	for j in list1[i]:
		for k in range(len(j)):
			list2[i].append(j[k])
list1 = list2
count = 0
for i in range(r):
	for j in range(c):
		if list1[i][j] == '.' and list1[i][j] != 0:
			temp = 0
			for k in range(r):
				if list1[k][j] == 'S':
					temp = 0
					break
				else:
					count += 1
					temp = 1
			if temp == 0:
				count = 0
			if temp == 1:
				for k in range(r):
					list1[k][j] = 0
count1 = 0
for i in range(c):
	for j in range(r):
		if list1[j][i] == '.' and list1[j][i] != 0:
			temp = 0
			for k in range(c):
				if list1[j][k] == 'S':
					temp = 0
					break
				else:
					count1 += 1
					temp = 1
			if temp == 0:
				count1 = 0
			if temp == 1:
				for k in range(c):
					list1[j][k] = 0
count = 0
for i in range(r):
	for j in range(c):
		if list1[i][j] == 0:
			count += 1
print(count)


n = [int(x) for x in input().split()]
x = []
y = []
for i in range(0, n[0]):
	t = input()
	for j in range(0, n[1]):
		if t[j] == 'S':
			if i in x:
				i = i
			else:
				x.append(i)
			if j in y:
				j = j
			else:
				y.append(j)
print(n[0] * n[1] - len(x) * len(y))


(r, c) = input().split()
r = int(r)
c = int(c)
clist = [0] * c
count = 0
kashi = c
rash = r
for i in range(r):
	llist = list(map(str, input()))
	flag = 1
	for j in range(c):
		if llist[j] == 'S':
			flag = 0
			clist[j] = 1
	if flag == 1:
		count += kashi
		rash -= 1
for item in clist:
	if item == 0:
		count += rash
print(count)


(x, y) = map(int, input().split())
p = []
k = []
num = x * y
for i in range(x):
	f = input()
	if 'S' in f:
		for j in range(len(f)):
			if f[j] == 'S':
				p.append(i)
				k.append(j)
for i in range(x):
	for j in range(y):
		if i in p and j in k:
			num -= 1
print(num)


(r, c) = map(int, input().split())
y = []
t = 0
for i in range(r):
	k = input()
	l = list(k)
	u = 0
	for j in range(len(l)):
		if l[j] == 'S':
			y.append(j)
			u = 1
	if u == 0:
		t = t + 1
y = set(y)
y = c - len(y)
print(y * r + (c - y) * t)


integer = int
string = str
length = len

def main():
	(r, c) = list(map(integer, input().split()))
	m = []
	row = 0
	column = 0
	for _ in range(r):
		temp = input()
		m.append(list(temp))
		if 'S' not in temp:
			row += 1
	m_t = list(zip(*m))
	for i in range(c):
		if 'S' not in m_t[i]:
			column += 1
	print(row * c + column * r - column * row)
main()


def Cakeminator():
	(rows, cols) = map(int, input().split())
	max_eat = 0
	rows_eat = 0
	grid = []
	for i in range(rows):
		row = input()
		if 'S' not in row:
			rows_eat += 1
			max_eat += cols
		grid.append(row)
	for i in range(cols):
		found = False
		for j in range(rows):
			if grid[j][i] == 'S':
				found = True
				break
		if not found:
			max_eat += rows - rows_eat
	return max_eat
remained_test_cases = 1
while remained_test_cases > 0:
	print(Cakeminator())
	remained_test_cases -= 1


(r, c) = map(int, input().split())
(rows, cols) = (set(), set())
for i in range(r):
	s = input()
	for (j, v) in enumerate(s):
		if v == 'S':
			rows.add(i)
			cols.add(j)
cake = [[1] * c] * r
count = 0
for i in range(r):
	if i not in rows:
		count += c
		cake[i] = [0] * c
for j in range(c):
	if j not in cols:
		count += sum([cake[i][j] for i in range(r)])
print(count)


(r, c) = map(int, input().split())
tort = []
for i in range(r):
	tort.append(input())
mas = [[False] * c for i in range(r)]
for i in range(r):
	if 'S' not in tort[i]:
		for j in range(c):
			mas[i][j] = True
for j in range(c):
	is_find = False
	for i in range(r):
		if tort[i][j] == 'S':
			is_find = True
			break
	if not is_find:
		for i in range(r):
			mas[i][j] = True
count = 0
for row in mas:
	count += row.count(True)
print(count)


(n, m) = (int(x) for x in input().split())
ans = 0
a = []
for i in range(n):
	a.append(input())
	if 'S' not in a[i]:
		ans += m
ans0 = ans
for i in range(m):
	k = 0
	for j in range(n):
		if a[j][i] == 'S':
			k = 1
	if k == 0:
		ans0 += n - ans // m
print(ans0)


(r, c) = map(int, input().split())
a = [input() for i in range(r)]
n = len([0 for s in a if 'S' not in s])
m = len([0 for j in range(c) if len([s[j] for s in a if s[j] == '.']) == r])
print(n * c + m * r - n * m)


(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) = 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:
		for j in range(c):
			if l[j] == 'S':
				e.append(j)
e = set(e)
print(count * c + ((c - len(e)) * r - (c - len(e)) * count))


import itertools as ittls
from collections import Counter

def inputarray(func=int):
	return map(func, input().split())
(n, m) = inputarray()
rows = [0] * n
cols = [0] * m
for i in range(n):
	s = input()
	for (j, v) in enumerate(s):
		if v == 'S':
			rows[i] = 1
			cols[j] = 1
x1 = n - sum(rows)
x2 = m - sum(cols)
r1 = x1 * m
r2 = x2 * n
print(r1 + r2 - x1 * x2)


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


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


(r, c) = map(int, input().split())
tort = []
for i in range(r):
	tort.append(input())
count = 0
for i in range(r):
	if 'S' not in tort[i]:
		tort[i] = tort[i].replace('.', '+')
		count += c
for j in range(c):
	res = ''
	for i in range(r):
		res += tort[i][j]
	if 'S' not in res:
		count += res.count('.')
print(count)


import sys

def main():
	cake = []
	(r, c) = list(map(int, sys.stdin.readline().split()))
	for i in range(r):
		cake.append(sys.stdin.readline().strip())
	row_count = 0
	for i in range(r):
		found_strawberry = False
		for j in range(c):
			if cake[i][j] == 'S':
				found_strawberry = True
				break
		if found_strawberry is False:
			row_count += 1
	col_count = 0
	for j in range(c):
		found_strawberry = False
		for i in range(r):
			if cake[i][j] == 'S':
				found_strawberry = True
				break
		if found_strawberry is False:
			col_count += 1
	print(row_count * c + col_count * r - row_count * col_count)

def __starting_point():
	return main()
__starting_point()


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


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
(N, M) = map(int, input().split())
A = []
for i in range(N):
	A.append(list(input()))
for r in range(N):
	if all([A[r][c] != 'S' for c in range(M)]):
		for c in range(M):
			A[r][c] = '1'
for c in range(M):
	if all([A[r][c] != 'S' for r in range(N)]):
		for r in range(N):
			A[r][c] = '1'
ans = 0
for r in range(N):
	for c in range(M):
		if A[r][c] == '1':
			ans += 1
print(ans)


(r, c) = map(int, input().split())
a = []
b = []
d = 0
for i in range(0, r):
	a = list(input())
	if 'S' not in a:
		a = [0] * c
		d = d + c
	b.append(a)
for i in range(0, c):
	k = 0
	m = 0
	for j in range(0, r):
		if b[j][i] == '.' or b[j][i] == 0:
			if b[j][i] == '.':
				m = m + 1
		else:
			k = 1
	if k == 0:
		d = d + m
print(d)


(n, m) = map(int, input().split())
ar = []
for i in range(n):
	t = list(input())
	for j in range(m):
		if 'S' == t[j]:
			ar.append((j, i))
r = len(ar)
for i in range(r):
	for j in range(i, r):
		if (ar[i][0], ar[j][1]) not in ar:
			ar.append((ar[i][0], ar[j][1]))
		if (ar[j][0], ar[i][1]) not in ar:
			ar.append((ar[j][0], ar[i][1]))
print(n * m - len(ar))


(n, m) = map(int, input().split())
a = []
l = 0
for j in range(n):
	s = input()
	if s.count('.') == m:
		l += m
		a.append('0' * m)
	else:
		a.append(s)
for i in range(m):
	k = 0
	for j in range(n):
		if a[j][i] == 'S':
			break
		elif a[j][i] == '.':
			k += 1
	else:
		l += k
print(l)


(n, m) = map(int, input().split())
a = []
for i in range(n):
	a.append(input())
for i in range(n):
	F = True
	for j in range(m):
		if a[i][j] == 'S':
			F = False
	if F:
		for j in range(m):
			a[i] = a[i][:j] + '1' + a[i][j + 1:]
for i in range(m):
	F = True
	for j in range(n):
		if a[j][i] == 'S':
			F = False
	if F:
		for j in range(n):
			a[j] = a[j][:i] + '1' + a[j][i + 1:]
ans = 0
for i in range(n):
	for j in range(m):
		if a[i][j] == '1':
			ans += 1
print(ans)


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


(r, c) = list(map(int, input().split()))
grid = []
score = 0
for i in range(r):
	grid.append(input())
for i in range(r):
	if 'S' not in grid[i]:
		score += c
		grid[i] = 'X' * c
for i in range(c):
	colfound = False
	colscore = 0
	for j in range(r):
		if grid[j][i] == 'S':
			colfound = True
		elif grid[j][i] == '.':
			colscore += 1
	if not colfound:
		score += colscore
print(score)


(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)


(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)


import sys, math, collections
from collections import defaultdict

def file():
	sys.stdin = open('input.py', 'r')
	sys.stdout = open('output.py', 'w')

def get_array():
	l = list(map(int, input().split()))
	return l

def get_2_ints():
	(a, b) = map(int, input().split())
	return (a, b)

def get_3_ints():
	(a, b, c) = map(int, input().split())
	return (a, b, c)

def sod(n):
	(n, c) = (str(n), 0)
	for i in n:
		c += int(i)
	return c

def getFloor(A, x):
	(left, right) = (0, len(A) - 1)
	floor = -1
	while left <= right:
		mid = (left + right) // 2
		if A[mid] == x:
			return A[mid]
		elif x < A[mid]:
			right = mid - 1
		else:
			floor = A[mid]
			left = mid + 1
	return floor

def main():
	(r, c) = get_2_ints()
	(row, colm) = ([], [])
	for i in range(r):
		l = input()
		for j in range(c):
			if l[j] == 'S':
				row.append(i)
				colm.append(j)
	row = list(set(row))
	colm = list(set(colm))
	print(r * c - len(row) * len(colm))
main()


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()


(r, c) = map(int, input().split())
(sr, sc) = (0, set())
for i in range(r):
	rw = input()
	if 'S' in rw:
		sr += 1
		for (j, ch) in enumerate(rw):
			if ch == 'S':
				sc.add(j)
print(r * c - sr * len(sc))


(r, c) = map(int, input().split())
l = [0] * r
for _ in range(r):
	a = input()
	l[_] = list(a)
for i in range(r):
	count = 0
	for j in range(c):
		if l[i][j] != 'S':
			count += 1
	if count == c:
		for k in range(c):
			l[i][k] = '1'
for col in range(c):
	cnt = 0
	for row in range(r):
		if l[row][col] != 'S':
			cnt += 1
	if cnt == r:
		for m in range(r):
			l[m][col] = '1'
total = sum([l[a][b] == '1' for a in range(r) for b in range(c)])
print(total)


(n, m) = map(int, input().split())
a = [1] * n
b = [1] * m
for i in range(n):
	l = list(input())
	while l.count('S') != 0:
		x = l.index('S')
		if x != -1:
			a[i] = 0
			b[x] = 0
			l[x] = '.'
c1 = a.count(1)
c2 = b.count(1)
if c1 == 0 and c2 == 0:
	print(0)
elif c1 == 0:
	print(c2 * n)
elif c2 == 0:
	print(c1 * m)
else:
	print(c1 * m + (n - c1) * c2)


(r, c) = [int(x) for x in input().split()]
cake = []
for i in range(0, r):
	row = list(input())
	cake.append(row)
rows = 0
cols = 0
for i in range(0, r):
	for j in range(0, c):
		if cake[i][j] == 'S':
			break
		if j == c - 1:
			rows += 1
for j in range(0, c):
	for i in range(0, r):
		if cake[i][j] == 'S':
			break
		if i == r - 1:
			cols += 1
print(rows * c + cols * r - rows * cols)


(r, c) = map(int, input().split())
l = []
s = 0
for i in range(r):
	l.append(input().replace('.', '1'))
	if 'S' not in l[i]:
		s += c
		l[i] = '0' * c
for i in range(c):
	tr = True
	count = 0
	for j in range(r):
		if l[j][i] == 'S':
			tr = False
			break
		elif l[j][i] == '1':
			count += 1
	if tr:
		s += count
print(s)


(rows, cols) = map(int, input().strip().split())
eats = 0
cake = []
for _ in range(rows):
	row = input().strip()
	if 'S' not in row:
		eats += cols
	else:
		cake.append(row)
rows = len(cake)
for col in range(cols):
	for row in cake:
		if row[col] == 'S':
			break
	else:
		eats += rows
print(eats)


(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)))


def ContainsDoubleEvil(r, c, row, col, board):
	evil = 0
	if board[row].count('S') > 0:
		evil += 1
	if [ro[col] for ro in board].count('S') > 0:
		evil += 1
	if evil == 2:
		return True
	else:
		return False

def Cake():
	(r, c) = list(map(int, input().split()))
	board = []
	for i in range(r):
		board.append(list(input()))
	count = 0
	for row in range(r):
		for col in range(c):
			if board[row][col] == 'S':
				pass
			elif ContainsDoubleEvil(r, c, row, col, board):
				pass
			else:
				count += 1
	print(count)
Cake()


x = [int(item) for item in input().split()]
row = []
column = []
anslist = []
for item in range(1, x[0] + 1):
	y = input()
	y = list(enumerate(y))
	for (a, b) in y:
		if b == 'S':
			row.append(item)
			column.append(a + 1)
for p in row:
	for q in column:
		anslist.append((p, q))
anslist = list(set(anslist))
print(x[0] * x[1] - len(anslist))


import sys

def read():
	return sys.stdin.readline()
a = []
(r, c) = map(int, read().split())
ans = 0
for i in range(r):
	a.append(list(read()))
for i in range(r):
	ok = False
	for j in range(c):
		if a[i][j] == 'S':
			ok = True
			break
	if ok == False:
		for j in range(c):
			a[i][j] = '*'
			ans += 1
for j in range(c):
	ok = False
	for i in range(r):
		if a[i][j] == 'S':
			ok = True
			break
	if ok == False:
		for i in range(r):
			if a[i][j] == '.':
				ans += 1
print(ans)


(r, c) = map(int, input().split())
a = [input() for i in range(r)]
print(r * c - len([1 for i in a if 'S' in i]) * len([1 for i in zip(*a) if 'S' in i]))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	(n, m) = LI()
	a = [S() for _ in range(n)]
	b = set()
	c = set()
	for i in range(n):
		for j in range(m):
			if a[i][j] == 'S':
				b.add(i)
				c.add(j)
	r = 0
	for i in range(n):
		for j in range(m):
			if i not in b or j not in c:
				r += 1
	return r
print(main())


(n, m) = map(int, input().split())
a = []
c = []
k = 0
for i in range(n):
	b = list(input())
	if not 'S' in b:
		k += 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':
				k += 1
	b = []
print(k)


(r, c) = [int(s) for s in input().split()]
a = []
counter = 0
for i in range(r):
	a.append([])
	for b in str(input()):
		a[i].append(b)
for i in range(r):
	if a[i].count('S') > 0:
		continue
	else:
		for j in range(c):
			if a[i][j] == '.':
				a[i][j] = '#'
				counter += 1
for i in range(c):
	flag = True
	for j in range(r):
		if a[j][i] == 'S':
			flag = False
			break
	if flag == True:
		for j in range(r):
			if a[j][i] == '.':
				a[j][i] = '#'
				counter += 1
print(counter)


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(set(nr))) * (c - len(set(nc)))
total = (r - len(set(nr))) * c + (c - len(set(nc))) * r
eat = total - common
if eat <= 0:
	print(0)
else:
	print(eat)


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


(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))


x = input().split(' ')
row = int(x[0])
col = int(x[1])
arr = []
for i in range(row):
	arr.append(input())
count = 0
indexes = []
for i in range(len(arr)):
	if 'S' not in arr[i]:
		count += len(arr[i])
		indexes.append(i)
for i in range(col):
	noS = False
	for j in range(row):
		if arr[j][i] == 'S':
			noS = True
			break
	if not noS:
		count += row
		if len(indexes) > 0:
			count -= len(indexes)
print(count)


(n, m) = map(int, input().split())
matrix = []
for i in range(n):
	matrix.append(input())
rows = [i for i in range(n)]
cols = [i for i in range(m)]
for i in range(n):
	for j in range(m):
		if matrix[i][j] == 'S':
			rows[i] = -1
			cols[j] = -1
p_r = list(filter(lambda x: x >= 0, rows))
p_c = list(filter(lambda x: x >= 0, cols))
print(len(p_c) * n + len(p_r) * m - len(p_r) * len(p_c))


__copyright__ = ''
__author__ = 'Son-Huy TRAN'
__email__ = 'sonhuytran@gmail.com'
__doc__ = 'http://codeforces.com/problemset/problem/330/A'
__version__ = '1.0'
(row, col) = map(int, input().split())
inputs = [''] * row
hasS = {'row': [0] * row, 'col': [0] * col}
for i in range(row):
	inputs[i] = input()
for i in range(row):
	for j in range(col):
		if inputs[i][j] == 'S':
			hasS['row'][i] = 1
			hasS['col'][j] = 1
rowcount = row - sum(hasS['row'])
colcount = col - sum(hasS['col'])
result = rowcount * col + colcount * row - rowcount * colcount
print(result)


arr = [int(i) for i in filter(None, input().split(' '))]
l = arr[1]
h = arr[0]
arr = []
last = []
c = []
for i in range(h):
	arr.append(list(input()))
for i in range(l * h):
	c.append(i)
for i in range(h):
	for j in range(l):
		if arr[i][j] != 'S':
			a = i * l + j
			arr[i][j] = c[a]
for i in range(l):
	vr = []
	for j in range(h):
		if arr[j][i] != 'S':
			vr.append(arr[j][i])
	if len(vr) == h:
		for j in range(h):
			if vr[j] not in last:
				last.append(vr[j])
for i in range(h):
	vr = []
	for j in range(l):
		if arr[i][j] != 'S':
			vr.append(arr[i][j])
	if len(vr) == l:
		for j in range(l):
			if vr[j] not in last:
				last.append(vr[j])
print(len(last))


lst = []
w = []
f = 0
a = 0
v = 0
z = list(map(int, input().split()))
for _ in range(z[0]):
	w = list(map(str, input()))
	lst.append(w)
for i in range(z[0]):
	if 'S' not in lst[i]:
		a += z[1]
for i in range(z[1]):
	for j in lst:
		if 'S' not in j[i]:
			v += 1
	if v == z[0]:
		f += z[0]
	v = 0
print(a + f - f // z[0] * (a // z[1]))


(a, b) = map(int, input().split())
(m, n, s) = ([], 0, 0)
for x in range(a):
	c = list(input())
	if 'S' not in c:
		s += b
		n += 1
	else:
		for y in range(b):
			if c[y] == 'S':
				m.append(y)
for x in range(b):
	if x not in m:
		s += a - n
print(s)


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


(r, c) = map(int, input().split())
p1 = []
p3 = []
p4 = []
for i in range(r):
	p2 = list(input())
	for j in range(c):
		if p2[j] != '.':
			p3.append(i)
			p4.append(j)
	p1.append(p2)
print(r * c - len(set(p3)) * len(set(p4)))


(r, c) = map(int, input().split())
grid = []
for i in range(r):
	s = list(input())
	grid.append(s)
row = set()
col = set()
for i in range(r):
	for j in range(c):
		if grid[i][j] == 'S':
			row.add(i)
			col.add(j)
cnt = 0
for i in range(r):
	if i not in row:
		t = 0
		for j in range(c):
			grid[i][j] = '#'
			t += 1
		cnt += t
for i in range(c):
	if i not in col:
		t = 0
		for j in range(r):
			if grid[j][i] == '.':
				grid[j][i] = '#'
				t += 1
		cnt += t
print(cnt)


(r, c) = map(int, input().split())
(row, colm) = ([], [])
for i in range(r):
	l = input()
	for j in range(c):
		if l[j] == 'S':
			row.append(i)
			colm.append(j)
row = list(set(row))
colm = list(set(colm))
print(r * c - len(row) * len(colm))


(r, c) = map(int, input().split())
m = []
for i in range(r):
	m.append(list(input()))
cells = 0
for i in range(len(m)):
	if m[i].count('S') == 0:
		cells += m[i].count('.')
		m[i] = ['E'] * len(m[i])
for i in range(len(m[0])):
	column = []
	for j in range(len(m)):
		column.append(m[j][i])
	stranberry = column.count('S')
	if stranberry == 0:
		cells += column.count('.')
print(cells)


(n, m) = map(int, input().split())
A = [0] * n
for k in range(n):
	A[k] = input()
B = [0] * m
for k in range(m):
	s = ''
	for j in range(n):
		s += A[j][k]
	B[k] = s
cont = 0
i = 0
for k in A:
	if not 'S' in k:
		cont += m
		i += 1
for k in B:
	if not 'S' in k:
		cont += n - i
print(cont)


(a, b) = map(int, input().split())
(c, d) = ([], [])
for i in range(a):
	c.append(input())
for i in range(b):
	e = ''
	for j in range(a):
		e += c[j][i]
	d.append(e)
eats = 0
for i in range(a):
	for j in range(b):
		if 'S' not in c[i] or 'S' not in d[j]:
			eats += 1
print(eats)


(n, m) = map(int, input().split())
g = [input() for i in range(n)]
print(sum([1 for i in range(n) for j in range(m) if g[i][j] == '.' and (not (any([g[i][k] == 'S' for k in range(m)]) and any([g[k][j] == 'S' for k in range(n)])))]))


(r, c) = map(int, input().split())
cake_row = []
for i in range(r):
	cake_row.append(input())
free_row = 0
for i in range(r):
	if 'S' not in cake_row[i]:
		free_row += 1
free_col = 0
for j in range(c):
	cake_col = ''.join([s[j] for s in cake_row])
	if 'S' not in cake_col:
		free_col += 1
print(free_col * (r - free_row) + free_row * c)


(n, m) = map(int, input().split())
a = [list(input()) for _ in range(n)]
(r, c) = (set(), set())
for i in range(n):
	ok = True
	for j in range(m):
		if a[i][j] == 'S':
			ok = False
	if ok:
		r.add(i)
for j in range(m):
	ok = True
	for i in range(n):
		if a[i][j] == 'S':
			ok = False
	if ok:
		c.add(j)
ans = 0
for i in range(n):
	if i in r:
		for j in range(m):
			ans += 1
			a[i][j] = 'S'
for j in range(m):
	if j in c:
		for i in range(n):
			ans += a[i][j] == '.'
print(ans)


def transpose(mat, n, m):
	z = []
	for i in range(m):
		k = []
		for j in range(n):
			k.append(mat[j][i])
		z.append(k)
	return z
(n, m) = map(int, input().split())
c = []
for i in range(n):
	l = list(input())
	c.append(l)
k = transpose(c, n, m)
p = 0
h = 0
v = 0
for i in range(len(c)):
	if c[i] == ['.'] * m:
		p += m
		h += 1
for i in range(len(k)):
	if k[i] == ['.'] * n:
		p += n
		v += 1
p -= h * v
print(p)


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


(n, m) = map(int, input().split())
M = [list(map(str, input())) for i in range(n)]
k = 0
for i in range(n):
	c = 1
	for j in range(m):
		if M[i][j] == 'S':
			c = 0
	if c == 1:
		for j in range(m):
			if M[i][j] == '.':
				k = k + 1
				M[i][j] = '0'
for j in range(m):
	c = 1
	for i in range(n):
		if M[i][j] == 'S':
			c = 0
	if c == 1:
		for i in range(n):
			if M[i][j] != '0':
				k = k + 1
print(k)


(r, c) = map(int, input().split())
l = []
for i in range(r):
	temp = input()
	l.append(temp)
rr = set()
cc = set()
for i in range(r):
	for j in range(c):
		if l[i][j] == 'S':
			rr.add(i)
			cc.add(j)
res = r * c - len(rr) * len(cc)
print(res)


x = input().split()
r = int(x[0])
c = int(x[1])
l = []
d = []
for i in range(r):
	l.append(input())
for j in range(r):
	if 'S' not in l[j]:
		for k in range(c):
			d.append(str(j) + str(k))
for a in range(c):
	w = 0
	for b in range(r):
		if l[b][a] != 'S':
			w += 1
	if w == r:
		for b in range(r):
			d.append(str(b) + str(a))
print(len(list(set(d))))


(x, y) = map(int, input().split())
t = 0
a = [input() for i in range(x)]
for i in range(x):
	if a[i].count('S') == 0:
		t = t + y
for j in range(y):
	flag1 = 1
	r = 0
	for k in range(x):
		if a[k].count('S') == 0:
			r = r + 1
		if a[k][j] == 'S':
			flag1 = 0
			break
	if k == x - 1 and flag1 == 1:
		t = t + x - r
print(t)


def main(r, c, seq):
	answer = 0
	for i in range(r):
		k = seq[i].count(1)
		if k == 0:
			for j in range(c):
				item = seq[i][j]
				if item == 0:
					seq[i][j] = 2
					answer += 1
	for i in range(c):
		temp = 0
		for j in range(r):
			item = seq[j][i]
			if item == 0:
				temp += 1
			elif item == 1:
				temp = 0
				break
		answer += temp
	return answer

def init():
	(r, c) = list(map(int, input().split()))
	seq = []
	for i in range(r):
		temp = []
		for item in input():
			if item == 'S':
				temp += [1]
			else:
				temp += [0]
		seq.append(temp)
	print(main(r, c, seq))
init()


s = input().split(' ')
t = []
z = []
r = int(s[0])
c = int(s[1])
y = 0
for i in range(r):
	a = input()
	x = []
	for k in range(c):
		x.append(a[k])
	t.append(x)
	z.append(x)
for j in range(r):
	if set(t[j]) == {'.'}:
		z.remove(t[j])
		y += c
for l in range(c):
	b = 0
	for m in range(len(z)):
		if z[m][l] == '.':
			b += 1
	if b == len(z):
		y += len(z)
print(y)


(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)


(a, b) = map(int, input().split())
tort = []
for i in range(a):
	tort.append(input())
mas = [[False] * b for i in range(a)]
for i in range(a):
	if 'S' not in tort[i]:
		for j in range(b):
			mas[i][j] = True
for j in range(b):
	f = False
	for i in range(a):
		if tort[i][j] == 'S':
			f = True
			break
	if not f:
		for i in range(a):
			mas[i][j] = True
R = 0
for i in range(a):
	for j in range(b):
		if mas[i][j]:
			R += 1
print(R)


t = input().split()
r = int(t[0])
c = int(t[1])
slon = 0
t = []
for i in range(r):
	temp = input()
	if temp.count('S') == 0:
		slon += c
	t.append(temp)
k = slon // c
for i in range(c):
	temp = 0
	for j in range(r):
		if t[j][i] == 'S':
			temp += 1
	if temp == 0:
		slon += r - k
print(slon)


gi = lambda : list(map(int, input().strip().split()))
(n, m) = gi()
cake = [input() for e in range(n)]
l = len([1 for e in cake if 'S' not in e])
c = len([1 for k in range(m) if 'S' not in [e[k] for e in cake]])
print(l * m + c * (n - l))


(n, m) = map(int, input().split())
s = []
r = 0
for i in range(n):
	s.append(list(input()))
for i in s:
	if 'S' not in i:
		t = i.count('.')
		r += t
		s[s.index(i)] = [' '] * m
s = list(zip(*s))
for i in s:
	if 'S' not in i:
		t = i.count('.')
		r += t
		s[s.index(i)] = [' '] * n
print(r)


(r, c) = map(int, input().split())
vals = []
for _ in range(r):
	vals.append(input())
res = 0
for i in range(r):
	if 'S' not in vals[i]:
		res += vals[i].count('.')
		vals[i] = '*' * len(vals[i])
for i in range(c):
	col = ''
	for j in range(r):
		col += vals[j][i]
	if 'S' not in col:
		res += col.count('.')
print(res)


(r, c) = map(int, input().split())
s = []
d = [[], []]
for i in range(r):
	s.append(input())
for i in s:
	if i.count('.') == c:
		d[0].append(c)
for i in range(c):
	h = 0
	for j in range(r):
		if s[j][i] == '.':
			h += 1
	if h == r:
		d[1].append(r)
a = sum(d[0]) + sum(d[1])
b = len(d[0]) * len(d[1])
print(a - b)


(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))))


(r, c) = map(int, input().split())
matrix = []
number = 0
count1 = 0
count2 = 0
for i in range(r):
	x = input()
	matrix.append(list(x[:c]))
for i in range(r):
	count = 0
	for j in range(c):
		if matrix[i][j] == 'S':
			break
	else:
		number += c
		count1 += 1
for j in range(c):
	for i in range(r):
		if matrix[i][j] == 'S':
			break
	else:
		number += r
		count2 += 1
print(number - count1 * count2)


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


(n, m) = map(int, input().split())
x = []
for i in range(n):
	x.append(list(input()))
c = 0
for i in range(n):
	s = 0
	b = 0
	for j in range(m):
		if x[i][j] == '.':
			b += 1
		if x[i][j] == 'S':
			s += 1
			break
	if s == 0:
		for j in range(m):
			x[i][j] = '0'
		c += b
for i in range(m):
	s = 0
	b = 0
	for j in range(n):
		if x[j][i] == '.':
			b += 1
		if x[j][i] == 'S':
			s += 1
			break
	if s == 0:
		c += b
print(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)


data = input()
data = data.split()
r = int(data[0])
c = int(data[1])
cake = []
for i in range(r):
	cake.append(input())

def delete_rows(cake):
	maxi = 0
	keys = []
	for (key, row) in enumerate(cake):
		if 'S' not in row:
			maxi = maxi + len(row)
			keys.append(key)
	count = 0
	for val in keys:
		cake.pop(val - count)
		count += 1
	return (cake, maxi)

def delete_columns(cake_columns):
	maxi = 0
	keys = []
	for (key, column) in enumerate(cake_columns):
		if 'S' not in column:
			maxi = maxi + len(column)
			keys.append(key)
	count = 0
	for val in keys:
		cake_columns.pop(val - count)
		count += 1
	return (cake_columns, maxi)

def inverse(cake):
	cake_columns = []
	for line in cake:
		if cake_columns == []:
			for cell in line:
				cake_columns.append(cell)
		else:
			value = 1
			for (key, column) in enumerate(cake_columns):
				column = column + line[key:value]
				cake_columns[key] = column
				value += 1
	return cake_columns

def is_posible(cake, maxi1, maxi2):
	maxi = maxi1 + maxi2
	posible = False
	values = [0 for _ in range(len(cake[0]))]
	for row in cake:
		for (key, cell) in enumerate(row):
			if cell == '.':
				values[key] += 1
	for val in values:
		if val == len(cake[0]):
			posible = True
	return (maxi, posible)
maxi = 0
(cake, maxi1) = delete_rows(cake)
cake_columns = inverse(cake)
(cake, maxi2) = delete_columns(cake_columns)
maxif = maxi1 + maxi2
print(maxif)


line = input()
line = line.split()
rows = int(line[0])
cols = int(line[1])
row = [0] * rows
col = [0] * cols
n = 0
m = cols
total = 0
for i in range(0, rows):
	line = input()
	chara = list(line)
	for j in range(0, cols):
		if chara[j] == 'S':
			row[i] = 1
			if col[j] != 1:
				m = m - 1
				col[j] = 1
	if row[i] == 0:
		n = n + 1
total = n * cols
total = total + m * (rows - n)
print(total)


(n, m) = map(int, input().split())
M = []
m1 = [['.' for j in range(m)] for i in range(n)]
for i in range(n):
	s = input()
	M.append(s)
ans = 0
for i in range(n):
	evil = False
	for j in range(m):
		if M[i][j] == 'S':
			evil = True
			break
	if not evil:
		for k in range(m):
			m1[i][k] = '1'
for i in range(m):
	evil = False
	for j in range(n):
		if M[j][i] == 'S':
			evil = True
			break
	if not evil:
		for k in range(n):
			m1[k][i] = '1'
for i in range(n):
	for j in range(m):
		if m1[i][j] == '1':
			ans += 1
print(ans)


(r, c) = [int(x) for x in input().split()]
cake = []
num = 0
for i in range(r):
	row = input()
	if '.' in row and 'S' not in row:
		cake.append('0' * c)
		num = num + c
	else:
		cake.append(row)
for j in range(c):
	column = [cake[i][j] for i in range(r)]
	if '.' in column and 'S' not in column:
		column_ = ''.join(column)
		num = num + column_.count('.')
print(num)


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


(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 - len(set(A)) * len(set(B)))


(r, c) = [int(string) for string in input().split()]
rows = []
for row in range(0, r):
	rows.append(list(input()))
clear_rows_count = 0
clear_cols_count = 0
for row in range(0, r):
	if rows[row].count('.') == c:
		clear_rows_count += 1
for col in range(0, c):
	dot_count = 0
	for row in range(0, r):
		if rows[row][col] == '.':
			dot_count += 1
	if dot_count == r:
		clear_cols_count += 1
print(clear_rows_count * c + clear_cols_count * r - clear_rows_count * clear_cols_count)


(row, column) = [int(x) for x in input().split()]
rowset = set([])
columnset = set([])
rowdone = 0
columndone = 0
for i in range(row):
	li = list(input())
	for (j, w) in enumerate(li):
		if w == 'S':
			rowset.add(i)
			columnset.add(j)
ans = 0
for i in range(row):
	if i not in rowset:
		ans += column - columndone
		rowdone += 1
for i in range(column):
	if i not in columnset:
		ans += row - rowdone
		columndone += 1
print(ans)


def string_to_list(a):
	y = []
	for i in range(len(a)):
		y.append(a[i])
	return y
a = list(map(int, input().split()))
(r, c, b) = (a[0], a[1], [])
for i in range(r):
	d = input()
	d1 = string_to_list(d)
	b.append(d1)
for i in range(c):
	es = 0
	for j in range(r):
		if b[j][i] == 'S':
			es += 1
			break
	if es == 0:
		for k in range(r):
			b[k][i] = 'E'
for i in range(r):
	es1 = 0
	for j in range(c):
		if b[i][j] == 'S':
			es1 += 1
			break
	if es1 == 0:
		for k in range(c):
			b[i][k] = 'E'
count = 0
for i in range(r):
	for j in range(c):
		if b[i][j] == 'E':
			count += 1
print(count)


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


(r, c) = [int(x) for x in input().split()]
lst = []
for _ in range(r):
	s = input()
	lst.append(list(s))
(eat, e) = (0, 0)
for i in lst:
	if 'S' not in i:
		eat += c
		e += 1
for i in range(c):
	no = 0
	for j in range(r):
		if lst[j][i] == 'S':
			no += 1
			break
	if no == 0:
		eat += r - e
print(eat)


(b, a) = map(int, input().split())
i = 0
j = 0
o = 0
bo = True
s = []
st = ''
t = [[0 for i in range(a)] for j in range(b)]
for i in range(0, b):
	for j in range(0, a):
		t[i][j] = 1
for i in range(0, b):
	st = str(input())
	s.append(st)
for i in range(0, b):
	for j in range(0, a):
		bo = True
		for k in range(0, a):
			if s[i][k] == 'S':
				bo = False
		if bo == True:
			for k in range(0, a):
				if t[i][k] != 0:
					t[i][k] = 0
					o += 1
		bo = True
		for k in range(0, b):
			if s[k][j] == 'S':
				bo = False
		if bo == True:
			for k in range(0, b):
				if t[k][j] != 0:
					t[k][j] = 0
					o += 1
		if i != 0:
			break
print(o)


(r, c) = list(map(int, input().split()))
str = []
for i in range(0, r):
	aLine = input()
	str.append(aLine)
res = 0
for i in range(0, r):
	k = 1
	for j in range(0, c):
		if str[i][j] == 'S':
			k = 0
			break
	if k == 1:
		res = res + c
		str[i] = ''
		for j in range(0, c):
			str[i] = str[i] + '0'
for j in range(0, c):
	k = 1
	for i in range(0, r):
		if str[i][j] == 'S':
			k = 0
			break
	if k == 1:
		for i in range(0, r):
			if str[i][j] == '.':
				res = res + 1
print(res)


(r, c) = list(map(int, input().split()))
l = [0] * c
h = [0] * r
a = []
for i in range(r):
	a.append([])
	ls = list(input())
	for j in range(c):
		a[i].append(ls[j])
		if a[i][j] != '.':
			l[j] = 1
			h[i] = 1
		else:
			a[i][j] = 1
t = 0
for i in range(r):
	if h[i] == 0:
		for j in range(c):
			t += a[i][j]
			a[i][j] = 0
for i in range(c):
	if l[i] == 0:
		for j in range(r):
			t += a[j][i]
			a[j][i] = 0
print(t)


(r, c) = map(int, input().split())
f = lambda x: 1 if x == '.' else 0
eat = 0
l = []
intersection = 0
for i in range(r):
	o = input()
	if o.find('S') != -1:
		l.append(list(map(f, list(o))))
	else:
		eat += c
		intersection += 1
l = zip(*l)
for k in list(l):
	if 0 not in k:
		eat += r - 1 * intersection
print(eat)


(n, m) = map(int, input().split())
a = [str(input()) for i in range(n)]
b = [0 for i in range(n)]
c = [0 for i in range(m)]
for i in range(n):
	for j in range(m):
		if a[i][j] == 'S':
			b[i] = 1
			c[j] = 1
print(n * m - sum(b) * sum(c))


(r, c) = map(int, input().split())
matrix = []
for _ in range(r):
	matrix.append(input())
(row, col) = (0, 0)
for i in range(r):
	if matrix[i].find('S') != -1:
		row += 1
for j in range(c):
	for i in range(r):
		if matrix[i][j] == 'S':
			col += 1
			break
print(r * c - row * col)


firstLine = [int(x) for x in input().split()]
height = firstLine[0]
width = firstLine[1]
total = 0
game = []
for i in range(0, height):
	game.append(str(input()))
	temp = width
	tempString = ''
	replace = True
	for j in range(0, len(game[-1])):
		if game[-1][j] == 'S':
			tempString += 'S'
			temp = 0
			replace = False
		else:
			tempString += 'X'
	if replace:
		game[-1] = tempString
	total += temp
for i in range(0, width):
	temp = 0
	for j in range(0, height):
		if game[j][i] == '.':
			temp += 1
		elif game[j][i] == 'S':
			temp = 0
			break
	total += temp
print(total)


(r, c) = map(int, input().split())
li = []
count = 0
for i in range(r):
	s = list(input())
	if 'S' not in s:
		count += c
		s = ['*'] * c
	li.append(s)
result = [[li[j][i] for j in range(len(li))] for i in range(len(li[0]))]
for i in range(c):
	s = result[i][0:r]
	if 'S' not in s:
		count += s.count('.')
print(count)


def cake(s):
	ans = 0
	for (i, n) in enumerate(s):
		if 'S' in n:
			continue
		else:
			s[i] = ['E'] * len(n)
			ans += len(n)
	x = list(zip(*s))
	for (i, n) in enumerate(x):
		if 'S' in n:
			continue
		else:
			ans += n.count('.')
	return ans
(r, c) = list(map(int, input().rstrip().split()))
s = []
for i in range(r):
	x = list(input())
	s.append(x)
print(cake(s))


(a, b) = map(int, input().split())
r = 0
k = [0] * b
for _ in ' ' * a:
	g = input()
	if 'S' not in g:
		r += b
	else:
		for i in range(b):
			if g[i] == 'S':
				k[i] = k[i] + 1
print(r + k.count(0) * a - r // b * k.count(0))


(a, b) = [int(i) for i in input().split()]
k = []
l = []
st = 0
ts = 0
trt = 0
for i in range(a):
	k.append(input())
	if 'S' not in k[i]:
		st += 1
		trt += b
for j in range(b):
	for f in range(a):
		if k[f][j] == 'S':
			break
	else:
		ts += 1
		trt += a
mn = st * ts
print(trt - mn)


(r, c) = list(map(int, input().split()))
L = []
for i in range(r):
	s = input()
	L.append(str(s))
ans = r * c
for i in range(r):
	for j in range(c):
		if L[i][j] == 'S':
			ans -= 1
			continue
		if 'S' in L[i]:
			case = False
			for z in range(r):
				if L[z][j] == 'S':
					case = True
					break
			if case:
				ans -= 1
print(ans)


X = list(map(int, input().split()))
Rows = list()
for i in range(X[0]):
	Rows.append(input())
Columns = list()
for i in range(X[1]):
	TempStr = str()
	for j in range(X[0]):
		TempStr += Rows[j][i]
	Columns.append(TempStr)
intRow = 0
intColumn = 0
for i in Rows:
	if 'S' not in i:
		intRow += 1
for i in Columns:
	if 'S' not in i:
		intColumn += 1
print(str(intRow * X[1] + intColumn * (X[0] - intRow)))


(r, c) = map(int, input().split())
w = []
for i in range(r):
	l = input()
	w.append(l)
rt = []
tu = 0
row = []
for i in range(r):
	cou = 0
	for j in range(c):
		cou += 1
		if w[i][j] == 'S':
			cou = 0
			break
	if cou > 0:
		row.append(i)
	tu += cou
for i in range(c):
	cou = 0
	for j in range(r):
		if j in row:
			rytu = 0
		else:
			cou += 1
			if w[j][i] == 'S':
				cou = 0
				break
	tu += cou
print(tu)


rows = [0] * 10
cols = [0] * 10
arr = input().split()
m = int(arr[0])
n = int(arr[1])
for i in range(m):
	arr = list(input())
	for j in range(n):
		if arr[j] == 'S':
			rows[i] = cols[j] = 1
r = n
c = m
ans = 0
for i in range(m):
	if rows[i] == 0:
		ans += r
		c -= 1
for i in range(n):
	if cols[i] == 0:
		ans += c
print(int(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)


from sys import stdin, stdout
import re

def solve():
	(r, c) = map(int, stdin.readline().split())
	sr = [1 for i in range(r)]
	sc = [1 for j in range(c)]
	for i in range(r):
		line = stdin.readline().strip()
		for j in range(c):
			if line[j] == 'S':
				sr[i] = 0
				sc[j] = 0
	ans = 0
	cake = [[0 for i in range(c)] for j in range(r)]
	for i in range(r):
		if sr[i] == 0:
			continue
		for j in range(c):
			if cake[i][j] == 0:
				cake[i][j] = 1
				ans += 1
	for j in range(c):
		if sc[j] == 0:
			continue
		for i in range(r):
			if cake[i][j] == 0:
				cake[i][j] = 1
				ans += 1
	print(ans)
LOCAL_TEST = not __debug__
if LOCAL_TEST:
	infile = __file__.split('.')[0] + '-test.in'
	stdin = open(infile, 'r')
tcs = int(stdin.readline().strip()) if LOCAL_TEST else 1
t = 1
while t <= tcs:
	solve()
	t += 1


(n, m) = map(int, input().split())
r = []
c = []
for i in range(n):
	x = input()
	for j in range(m):
		if x[j] == 'S':
			r.append(i)
			c.append(j)
r = len(list(set(r)))
c = len(list(set(c)))
print(n * m - r * c)


(r, c) = input().split()
r = int(r)
c = int(c)
rows = []
evils = 0
for i in range(r):
	rows.append(input())
	evils += rows[-1].count('S')
eaten = r * c - evils
columns = []
for i in range(c):
	L = []
	for j in range(r):
		L.append(rows[j][i])
	columns.append(L)
for i in range(r):
	for j in range(c):
		if rows[i][j] == 'S':
			continue
		elif 'S' in rows[i] and 'S' in columns[j]:
			eaten -= 1
print(eaten)


(x, y) = input().split()
(a, b) = (int(x), int(y))
(row, coloum) = (0, 0)
list = []
for i in range(a):
	list.append(input())
for i in range(a):
	if 'S' not in list[i]:
		row = row + 1
for i in range(b):
	if 'S' not in [row[i] for row in list]:
		coloum = coloum + 1
print(row * b + coloum * a - row * coloum)


(r, c) = map(int, input().split())
(arr, flag, ans) = ([], 0, 0)
for _ in range(r):
	arr.append(list(input()))
for i in range(r):
	for j in range(c):
		if arr[i][j] == 'S':
			flag = 1
			break
	if flag == 0:
		for j in range(c):
			if arr[i][j] == '.':
				arr[i][j] = 'E'
				ans += 1
	flag = 0
flag = 0
for i in range(c):
	for j in range(r):
		if arr[j][i] == 'S':
			flag = 1
			break
	if flag == 0:
		for j in range(r):
			if arr[j][i] == '.':
				ans += 1
				arr[j][i] = 'E'
	flag = 0
print(ans)


import sys
from math import sqrt, gcd, ceil, log, floor
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda : list(map(int, input().strip().split()))

def main():
	(n, m) = read()
	arr = []
	row = set()
	col = set()
	for i in range(n):
		s = input().strip()
		for j in range(m):
			if s[j] == 'S':
				row.add(i)
				col.add(j)
	ans = (n - len(row)) * m + (m - len(col)) * n - (n - len(row)) * (m - len(col))
	print(ans)
main()


(r, c) = map(int, input().split())
row = []
col = []
arr = []
for i in range(r):
	line = input()
	arr.append(line)
	if 'S' not in line:
		row.append(i)
for j in range(c):
	count = 0
	for i in range(r):
		if arr[i][j] != 'S':
			count = count + 1
	if count == r:
		col.append(j)
ans = len(row) * c + len(col) * r - len(row) * len(col)
print(ans)


(row, c) = map(int, input().split())
arr = []
for _ in range(row):
	arr.append([k for k in map(str, input())])
cakes = 0
row_cn = 0
for r in arr:
	if r.count('.') == c:
		cakes += c
		row_cn += 1
for col in zip(*arr):
	if col.count('.') == row:
		cakes += row - row_cn
print(cakes)


(r, c) = map(int, input().split())
cake = []
eat = 0
TransCake = []
for i in range(r):
	cake.append(input())
for i in range(r):
	if 'S' in cake[i]:
		continue
	else:
		eat += c
		cake[i] = '0' * c
for i in range(c):
	TransCake.append([])
	for j in range(r):
		TransCake[i].append(cake[j][i])
	if 'S' in TransCake[i]:
		continue
	else:
		eat += TransCake[i].count('.')
print(eat)


(r, c) = [int(x) for x in input().split()]
lst = []
for i in range(r):
	t = input()
	temp = []
	for i in range(c):
		temp.append(t[i])
	lst.append(temp)
count = 0
for i in range(r):
	if 'S' not in lst[i]:
		for j in range(c):
			if lst[i][j] == '.':
				count += 1
				lst[i][j] = 'e'
lst2 = []
for i in range(c):
	temp2 = []
	for j in range(r):
		temp2.append(lst[j][i])
	lst2.append(temp2)
for i in range(c):
	if 'S' not in lst2[i]:
		for j in range(r):
			if lst2[i][j] == '.':
				count += 1
				lst2[i][j] = 'e'
print(count)


(r, c) = [int(i) for i in input().split()]
mass = []
res_evil = 0
col_evil = 0
for i in range(r):
	s = input()
	mass.append(s)
	if s.find('S') != -1:
		res_evil += 1
for j in range(c):
	for i in range(r):
		if mass[i][j] == 'S':
			col_evil += 1
			break
print(r * c - res_evil * col_evil)


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))
(r, c) = get_int_list()
matrix = [0] * r
for i in range(r):
	matrix[i] = get_charList_from_str()
count = 0
for i in range(r):
	if 'S' not in matrix[i]:
		count += matrix[i].count('.')
		matrix[i] = list(''.join(matrix[i]).replace('.', '#'))
for j in range(c):
	temp = [matrix[i][j] for i in range(r)]
	if 'S' not in temp:
		count += temp.count('.')
print(count)


(r, c) = map(int, input().split())
a = []
k = 0
for _ in range(r):
	x = str(input())
	a.append(x)
for _ in range(len(a)):
	if 'S' not in a[_]:
		a[_] = [':'] * c
		k += c
b = [[a[j][i] for j in range(len(a))] for i in range(len(a[0]))]
for _ in range(len(b)):
	if 'S' not in b[_]:
		k += b[_].count('.')
print(k)


(r, c) = map(int, input().split())
cek = set()
hasil = 0
makan = 0
for i in range(r):
	masukan = input()
	ada = False
	for j in range(c):
		if masukan[j] == 'S':
			cek.add(j)
			ada = True
	if not ada:
		hasil += c
		makan += 1
hasil += (c - len(cek)) * (r - makan)
print(hasil)


(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)


(n, m) = map(int, input().split())
a = []
t = count = 0
flag = True
for i in range(n):
	a.append([s for s in input().replace('', ' ').strip().split()])
for i in range(n):
	if 'S' not in a[i]:
		t += 1
		count += len(a[i])
for i in range(m):
	flag = True
	for j in range(n):
		if a[j][i] == 'S':
			flag = False
		elif j == n - 1 and flag:
			count += n - t
print(count)


(x, y) = map(int, input().split())
l = []
m = []
for i in range(x):
	s = input()
	for j in range(y):
		if s[j] == 'S':
			l.append(i)
			m.append(j)
print(x * y - len(list(set(l))) * len(list(set(m))))


(r, c) = (int(x) for x in input().split())
cake = []
for i in range(0, r):
	cake.append(list(input()))
eats = 0
for i in range(0, r):
	flag = 0
	currEats = 0
	for j in range(0, c):
		if cake[i][j] == 'S':
			flag = 1
			break
	if flag != 1:
		for j in range(0, c):
			if cake[i][j] == '.':
				eats = eats + 1
				cake[i][j] = '!'
for j in range(0, c):
	flag = 0
	currEats = 0
	for i in range(0, r):
		if cake[i][j] == 'S':
			flag = 1
			break
	if flag != 1:
		for i in range(0, r):
			if cake[i][j] == '.':
				eats = eats + 1
				cake[i][j] = '!'
print(eats)


(r, c) = map(int, input().split())
a = [input() for i in range(r)]
t1 = set()
t2 = set()
for i in range(r):
	for j in range(c):
		if a[i][j] == 'S':
			t1.add(i)
			t2.add(j)
n = r - len(t1)
m = c - len(t2)
print(n * c + m * r - n * m)


a = [int(i) for i in input().split(' ')]
rows = a[0]
cols = a[1]
a = [[x for x in input()] for i in range(rows)]
c = 0
for i in range(rows):
	if a[i].count('S') == 0:
		for j in range(cols):
			if a[i][j] == '.':
				a[i][j] = 'e'
				c += 1
for i in range(cols):
	b = []
	for x in range(rows):
		b.append(a[x][i])
	if b.count('S') == 0:
		for j in range(rows):
			if b[j] == '.':
				a[j][i] = 'e'
				c += 1
print(c)


(r, c) = map(int, input().split())
counter = 0
d = []
step = 0
for i in range(r):
	s = input()
	if 'S' in s:
		for j in range(len(s)):
			if s[j] == 'S':
				d.append(j)
	else:
		counter += 1
		step += c
d = set(d)
for i in range(c):
	if i not in d:
		step += r - counter
print(step)


(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)


(r, c) = map(int, input().split())
a = [[]]
x = set()
y = set()
for i in range(r):
	a.insert(i, list(input()))
for i in range(r):
	for j in range(c):
		if a[i][j] == 'S':
			x.add(j)
			y.add(i)
print(r * c - len(x) * len(y))


(r, c) = [int(i) for i in input().split()]
lst = []
berries = [set(), set()]
for i in range(r):
	lst.append(input())
	for j in range(c):
		if lst[i][j] == 'S':
			berries[0].add(i)
			berries[1].add(j)
cells = 0
for i in range(r):
	for j in range(c):
		if lst[i][j] == '.' and (i not in berries[0] or j not in berries[1]):
			cells += 1
print(cells)


s = input().split()
a = int(s[0])
b = int(s[1])
mat = []
sat = []
pat = []
res = 0
for i in range(a):
	f = input()
	for l in f:
		pat.append(l)
	mat.append(pat)
	pat = []
for i in range(a):
	if 'S' in mat[i]:
		pass
	else:
		for j in range(b):
			if mat[i][j] == '.':
				res += 1
				mat[i][j] = 't'
for i in range(b):
	for j in range(a):
		sat.append(mat[j][i])
	if not 'S' in sat:
		for k in sat:
			if k == '.':
				res += 1
	sat = []
print(res)


(r, c) = map(int, input().split())
li = [[0 for i in range(c)] for j in range(r)]
for i in range(r):
	string = input()
	for j in range(c):
		li[i][j] = string[j]
count = 0
flag = True
for i in range(r):
	for j in range(c):
		if li[i][j] == 'S':
			flag = False
			break
	if flag:
		for j in range(c):
			if li[i][j] != '-':
				count += 1
				li[i][j] = '-'
	flag = True
flag = True
for j in range(c):
	for i in range(r):
		if li[i][j] == 'S':
			flag = False
			break
	if flag:
		for i in range(r):
			if li[i][j] != '-':
				count += 1
				li[i][j] = '-'
	flag = True
print(count)


from sys import stdin, stdout
input = stdin.readline
(r, s) = map(int, input().split())
cake = [list(input()) for _ in range(r)]
for i in range(r):
	if not 'S' in cake[i]:
		cake[i] = ['#'] * s
for i in range(s):
	f = False
	for j in range(r):
		if cake[j][i] == 'S':
			f = True
	if not f:
		for j in range(r):
			cake[j][i] = '#'
ans = 0
for i in cake:
	ans += i.count('#')
stdout.write(str(ans))


(n, m) = map(int, input().split())
g = [input() for i in range(n)]
print(n * m - len([1 for i in g if 'S' in i]) * len([1 for i in zip(*g) if 'S' in i]))


import math
from collections import *
import sys
from functools import reduce

def get_ints():
	return map(int, input().strip().split())

def get_list():
	return list(get_ints())

def get_string():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
UGLYMOD = int(1000000000.0) + 7
SEXYMOD = 998244353
MAXN = int(100000.0)
(n, m) = get_ints()
rows = set()
cols = set()
matr = []
for i in range(n):
	matr.append(list(input()))
for i in range(n):
	for j in range(m):
		if matr[i][j] == 'S':
			rows.add(i)
			cols.add(j)
print(n * m - len(rows) * len(cols))


(length, width) = map(int, input().split())
ans = []
cnt = 0
for x in range(length):
	ans.append(list(input()))
for (index, x) in enumerate(ans):
	if 'S' not in x:
		cnt += len(x)
		ans[index] = []
ans = [x for x in ans if x != []]
cnt2 = 0
try:
	for x in range(len(ans[0])):
		for z in ans:
			if z[x] != 'S':
				cnt2 += 1
			else:
				cnt2 = 0
				break
		else:
			cnt += cnt2
			cnt2 = 0
except IndexError:
	pass
print(cnt)


(r, c) = (int(x) for x in input().split())
field = []
for x in range(r):
	field.append([x for x in input()])
ans = 0
for y in range(c):
	has_s = False
	for x in range(r):
		if field[x][y] == 'S':
			has_s = True
			break
	if not has_s:
		for x in range(r):
			if field[x][y] == '.':
				ans += 1
				field[x][y] = 0
for x in range(r):
	if 'S' not in field[x]:
		for y in range(c):
			if field[x][y] == '.':
				ans += 1
				field[x][y] = 0
print(ans)


(n, m) = map(int, input().split())
A = []
cells = 0
for i in range(n):
	a = input()
	A.append(a)
for i in range(len(A)):
	if 'S' not in A[i]:
		for j in A[i]:
			if j == '.':
				cells += 1
				A[i] = A[i].replace(j, '*')
t = ''
B = []
for i in range(m):
	for j in A:
		t += j[i]
	B.append(t)
	t = ''
for i in B:
	if 'S' not in i:
		for j in i:
			if j == '.':
				cells += 1
print(cells)


(n, m) = map(int, input().split())
a = []
t = 0
s = 0
for i in range(n):
	a.append(input())
for i in range(n):
	for j in range(m):
		if 'S' not in a[i]:
			t += 1
b = []
c = []
for i in range(m):
	for j in range(n):
		if 'S' in a[j][i]:
			b.append(i)
		elif i not in c:
			c.append(i)
for i in range(len(b)):
	if b[i] in c:
		c.remove(b[i])
s = t + len(c) * n
print(s - t // m * len(c))


(r, c) = map(int, input().split())
a = []
b = list(([] for j in range(c)))
n = 0
for i in range(r):
	s = input()
	if not 'S' in s:
		n += c
	else:
		for k in range(c):
			b[k] += s[k]
for k in b:
	if not 'S' in k:
		n += k.count('.')
print(n)


(ro, co) = map(int, input().split())
row = []
k = 0
rou = 0
for i in range(ro):
	row.append(list(input()))
	if 'S' not in row[i]:
		rou += 1
		k += co
for i in range(co):
	l = 0
	for j in range(ro):
		if row[j][i] == 'S':
			l = 1
			break
	if l == 0:
		k += ro - rou
print(k)


(r, c) = [int(elem) for elem in input().split()]
cake = [''] * r
for i in range(r):
	cake[i] = input()
coloms = [str(elem) for elem in list(range(c))]
for i in range(len(cake)):
	for j in range(len(cake[0])):
		if cake[i][j] == 'S':
			if coloms.count(str(j)) != 0:
				coloms.remove(str(j))
count = len(coloms) * r
rows = [str(elem) for elem in list(range(r))]
for i in range(len(cake)):
	for j in range(len(cake[0])):
		if cake[i][j] == 'S':
			if rows.count(str(i)) != 0:
				rows.remove(str(i))
count += len(rows) * (c - len(coloms))
print(count)


(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)


s = input().split()
(r, c) = (int(s[0]), int(s[1]))
l = [None] * r
cnt_r = cnt_c = 0
for i in range(r):
	s = input()
	if s.find('S') == -1:
		cnt_r += 1
	l[i] = s
tl = [''.join(s) for s in zip(*l)]
for i in range(c):
	if tl[i].find('S') == -1:
		cnt_c += 1
print(cnt_r * c + cnt_c * r - cnt_r * cnt_c)


(r, c) = map(int, input().split())
rows = 0
cols = 0
lines = []
for i in range(r):
	row = input()
	lines.append(row)
	if 'S' in row:
		rows += 1
for i in range(c):
	col = ''
	for j in range(r):
		col += lines[j][i]
	if 'S' in col:
		cols += 1
print(r * c - rows * cols)


st = input().split()
r = int(st[0])
c = int(st[1])
g = []
blk = ''
for i in range(c):
	blk += '_'
for i in range(r):
	g.append(input())
eaten = 0
for i in range(r):
	if not 'S' in str(g[i]):
		eaten += c
		g[i] = blk
for i in range(c):
	eadible = True
	for j in range(r):
		if g[j][i] == 'S':
			eadible = False
	if eadible:
		for j in range(r):
			if g[j][i] == '.':
				eaten += 1
print(eaten)


(r, c) = map(int, input().split())
list1 = []
for i in range(r):
	ll = list(input())
	list1.append(ll)
x = 0
y = 0
lr = []
lc = []
for i in range(r):
	f = 0
	for j in range(c):
		if list1[i][j] == 'S':
			f = 1
	if f == 0:
		x += 1
	else:
		lr.append(i)
for i in range(c):
	f = 0
	for j in range(r):
		if list1[j][i] == 'S':
			f = 1
	if f == 0:
		y += 1
	else:
		lc.append(i)
count = 0
for i in range(r):
	for j in range(c):
		if i in lr and j in lc:
			count += 1
print(r * c - count)


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)
	return r * c - len(rows) * len(collumns)
(r, c) = map(int, input().split())
l = []
for _ in range(r):
	l.append(input())
print(solve(r, c, l))


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())
l = []
pr = set()
pc = set()
for i in range(r):
	l.append(input())
	if 'S' in l[i]:
		pr.add(i)
		for (idx, element) in enumerate(l[i]):
			if element == 'S':
				pc.add(idx)
cells = (r - len(pr)) * c
cells += (c - len(pc)) * len(pr)
print(cells)


(r, c) = map(int, input().split())
arr = []
rows = 0
cols = 0
for i in range(r):
	arr.append(input())
for i in range(r):
	if 'S' not in arr[i]:
		rows += 1
for i in range(c):
	temp = 0
	for j in range(r):
		if arr[j][i] != 'S':
			temp += 1
	if temp == r:
		cols += 1
print(rows * c + cols * r - rows * cols)


rc = input().split()
r = int(rc[0])
c = int(rc[1])
l = []
x = 0
y = 0
for i in range(r):
	l.append(input())
for i in range(r):
	for j in range(c):
		if l[i][j] == 'S':
			x = x + 1
			break
for i in range(c):
	for j in range(r):
		if l[j][i] == 'S':
			y = y + 1
			break
print(r * c - x * y)


(r, c) = list(map(int, input().split()))
p = ''
x = y = 0
for i in range(r):
	a = input()
	p = p + a
	if a.count('S') == 0:
		x = x + c
for i in range(c):
	if p[i::c].count('S') == 0:
		y = y + r - x // c
print(x + y)


(n, m) = list(map(int, input().split()))
xl = []
l = []
for _ in range(n):
	xl.append(list(input()))
c = 0
l = xl.copy()
for x in xl:
	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(x)
print(c)


x = [int(x) for x in input().split()]
r = x[0]
c = x[1]
a = 0
v = []
for i in range(r):
	it = input()
	v.append(it)
	if it.count('S') == 0:
		a += 1
b = 0
for j in range(c):
	l = ''
	for k in range(r):
		l += v[k][j]
	if l.count('S') == 0:
		b += 1
print(a * c + b * r - a * b)


(r, c) = map(int, input().split())
mas = [list(input()) for i in range(r)]
for i in range(r):
	if not 'S' in mas[i]:
		mas[i] = [1] * c
for p in range(c):
	find_S = False
	for i in range(r):
		if mas[i][p] == 'S':
			find_S = True
			break
	if not find_S:
		for i in range(r):
			mas[i][p] = 1
k = 0
for m in mas:
	k += m.count(1)
print(k)


row = {}
column = {}
(n, m) = map(int, input().split())
matrix = []
for i in range(n):
	matrix.append(list(input()))
for i in range(n):
	row[i] = False
for j in range(m):
	column[j] = False
for i in range(n):
	for j in range(m):
		if matrix[i][j] == 'S':
			row[i] = True
			column[j] = True
cnt = m * n
for i in range(n):
	for j in range(m):
		if matrix[i][j] == 'S' or (row[i] and column[j]):
			cnt -= 1
print(cnt)


(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, input().split())
st = [input() for _ in range(n)]
col = []
for j in range(m):
	a = ''
	for i in range(n):
		a += st[i][j:j + 1]
	col.append(a)
count = 0
count_st = 0
for i in range(n):
	if 'S' not in st[i]:
		count += m
		count_st += 1
for j in range(m):
	if 'S' not in col[j]:
		count += n - count_st
print(count)


(r, c) = input().split()
(r, c) = (int(r), int(c))
lis = []
for i in range(r):
	lis.append(input())
	lis[i] = list(lis[i])
count = lis.count(['.' for j in range(c)])
cake = count * c
lis1 = []
for k in lis:
	if k != ['.' for j in range(c)]:
		lis1.append(k)
lis2 = [[0 for i in range(r - count)] for j in range(c)]
for i in range(r - count):
	for j in range(c):
		lis2[j][i] = lis1[i][j]
cake += lis2.count(['.' for j in range(r - count)]) * (r - count)
print(cake)


def cake(n, m, grid):
	c = 0
	r = 0
	for i in grid:
		if 'S' in i:
			r += 1
	new = []
	for i in range(m):
		temp = []
		temp = [grid[j][i] for j in range(n)]
		new.append(temp)
	for i in new:
		if 'S' in i:
			c += 1
	return n * m - r * 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(cake(n, m, grid))


(n, M) = map(int, input().split())
A = []
B = []
for i in range(n):
	m = input()
	for j in range(len(m)):
		if m[j] == 'S':
			if not j in B:
				B.append(j)
			if not i in A:
				A.append(i)
s = 0
s += M * (n - len(A))
s += len(A) * (M - len(B))
print(s)


(R, C) = map(int, input().split())
G = [list(input()) for r in range(R)]

def count_cells(R, C):
	ret = 0
	for r in range(R):
		valid = True
		for c in range(C):
			if G[r][c] == 'S':
				valid = False
				break
		if valid:
			for c in range(C):
				if G[r][c] == '.':
					ret += 1
					G[r][c] = 'X'
	for c in range(C):
		valid = True
		for r in range(R):
			if G[r][c] == 'S':
				valid = False
				break
		if valid:
			for r in range(R):
				if G[r][c] == '.':
					ret += 1
					G[r][c] = 'X'
	return ret
print(count_cells(R, C))


(r, c) = map(int, input().split())
maze = []
for i in range(r):
	maze.append(input())
rr = [True for _ in range(r)]
cc = [True for _ in range(c)]
for i in range(r):
	for j in range(c):
		if maze[i][j] == 'S':
			rr[i] = False
			cc[j] = False
ans = 0
rtrue = 0
for i in range(r):
	if rr[i]:
		ans += c
		rtrue += 1
ctrue = 0
for j in range(c):
	if cc[j]:
		ans += r
		ctrue += 1
ans -= rtrue * ctrue
print(ans)


import sys
from math import *
input = sys.stdin.readline
RI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw = lambda : input().strip().split()
from collections import defaultdict as df
import heapq
infinite = float('inf')
(n, m) = RI()
l = [[] for i in range(n)]
for i in range(n):
	l[i] = list(input().strip())
for i in range(n):
	f = 0
	for j in range(m):
		if l[i][j] == 'S':
			f = 1
			break
	if f == 0:
		for j in range(m):
			l[i][j] = 1
for i in range(m):
	f = 0
	for j in range(n):
		if l[j][i] == 'S':
			f = 1
			break
	if f == 0:
		for j in range(n):
			l[j][i] = 1
c = 0
for i in range(n):
	for j in range(m):
		if l[i][j] == 1:
			c += 1
print(c)


(r, c) = list(map(int, input().split()))
(l, S) = ([], [[], []])
h_sum = 0
v_sum = 0
intersects = 0
for i in range(r):
	l.append(input())
for i in range(c):
	count = 0
	for j in range(r):
		if l[j][i] == '.':
			count += 1
	if count == r:
		h_sum += r
for i in range(r):
	count = 0
	for j in range(c):
		if l[i][j] == '.':
			count += 1
	if count == c:
		v_sum += c
for i in range(r):
	for j in range(c):
		if l[i][j] == 'S':
			S[0].append(i)
			S[1].append(j)
for i in range(r):
	if i not in S[0]:
		for j in range(c):
			if j not in S[1]:
				intersects += 1
print(h_sum + v_sum - intersects)


(n, m) = map(int, input().split())
row_flags = [False] * n
col_flags = [False] * m
for i in range(n):
	has_s = False
	for (j, v) in enumerate(input()):
		if v == 'S':
			has_s = True
			col_flags[j] = True
	if has_s:
		row_flags[i] = True
print(n * m - sum(row_flags) * sum(col_flags))


(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())
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)))


(r, c) = [int(item) for item in input().split()]
mat = [[s for s in input()] for _ in range(r)]
count = 0
rows = 0
cols = set()
d = {}
for i in range(r):
	if 'S' not in mat[i]:
		rows += 1
	for j in range(c):
		if 'S' == mat[i][j]:
			cols.add(j)
count = (c - len(cols)) * (r - rows) + rows * c
print(count)


(m, n) = map(int, input().split(' '))
m_set = set()
n_set = set()
for a in range(m):
	s = input()
	for (b, c) in enumerate(s):
		if c == 'S':
			m_set.add(a)
			n_set.add(b)
print(m * n - len(m_set) * len(n_set))


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
main()


(r, c) = [int(i) for i in input().split()]
s = 0
l = []
num = 0
nu = 0
for i in range(r):
	a = input()
	if 'S' not in a:
		s += c
		num += 1
	l.append(a)
for i in range(c):
	k = 0
	for j in range(r):
		if l[j][i] == 'S':
			break
		else:
			k += 1
	if k == r:
		s += r
		nu += 1
print(s - num * nu)


(r, c) = map(int, input().split())
arr = []
row = []
col = []
total = tot = 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:
		tot += c
for j in range(c):
	if j not in col:
		total += r - tot // c
print(total + tot)


(a, b) = map(int, input().split())
eat = 0
ate = 0
cake = []
for i in range(a):
	x = list(input())
	cake.append(x)
	if 'S' not in x:
		eat += b
		ate += 1
for j in range(b):
	stat = 'clean'
	for k in range(a):
		if cake[k][j] == 'S':
			stat = 'evil'
	if stat == 'clean':
		eat += a - ate
print(eat)


(n, m) = (int(i) for i in input().split())
l = [input() for i in range(n)]
a = []
for i in range(n):
	for j in range(m):
		if l[i][j] == 'S':
			a.append([i, j])
for i in range(len(a)):
	for j in range(len(a)):
		if [a[i][0], a[j][1]] not in a:
			a.append([a[i][0], a[j][1]])
print(n * m - len(a))


def main():
	(r, c) = map(int, input().split())
	k = list()
	for i in range(r):
		k.append([char for char in input()])
	columns = 0
	rows = 0
	for i in range(r):
		if 'S' not in k[i]:
			rows += 1
	for i in range(c):
		if 'S' not in [k[j][i] for j in range(r)]:
			columns += 1
	print(rows * c + columns * r - rows * columns)
main()


(r, c) = list(map(int, input().split()))
q = []
for i in range(0, r):
	a = input()
	p = []
	for j in a:
		p.append(j)
	q.append(p)
z = 0
w = 0
for i in range(0, r):
	if 'S' not in q[i]:
		w = w + 1
		z = z + c
for i in range(0, c):
	f = 0
	for j in range(0, r):
		if q[j][i] == 'S':
			f = 1
			break
	if f == 0:
		z = z + r - w
print(z)


(r, c) = map(int, input().split())
spiska = []
rrr = []
ccc = []
for i in range(r):
	spiska.append(input().strip())
for i in range(r):
	for j in range(c):
		if spiska[i][j] == 'S':
			rrr.append(i + 1)
			ccc.append(j + 1)
rrr = set(rrr)
ccc = set(ccc)
print((r - len(rrr)) * c + (c - len(ccc)) * r - (r - len(rrr)) * (c - len(ccc)))


(n, m) = list(map(int, input().split()))
arr = [input() for _ in range(n)]
set1 = []
set2 = []
for i in range(n):
	for j in range(m):
		if arr[i][j] == 'S':
			set1.append(i)
			set2.append(j)
len1 = int(n - len(set(set1)))
len2 = int(m - len(set(set2)))
print(len1 * m + len2 * n - len2 * len1)


(a, b) = tuple(map(int, input().split()))
free_rows = [i for i in range(a)]
free_cols = [i for i in range(b)]
for i in range(a):
	row = input()
	if 'S' in row:
		free_rows.remove(i)
	for j in range(b):
		if row[j] == 'S':
			if j in free_cols:
				free_cols.remove(j)
print(len(free_rows) * b + len(free_cols) * a - len(free_rows) * len(free_cols))


(n, m) = list(map(int, input().split()))
a = []
for _ in range(n):
	a.append(input())
row = set()
column = set()
for i in range(len(a)):
	for j in range(len(a[i])):
		if a[i][j] == 'S':
			row.add(j)
			column.add(i)
print((n - len(column)) * m + (m - len(row)) * n - (n - len(column)) * (m - len(row)))


(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':
			b = 1
			break
		else:
			d.append(j * c + i + 1)
	if b == 0:
		for i in d:
			a.append(i)
print(len(set(a)))


(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)


s = input('')
(n, m) = s.split(' ')
n = int(n)
m = int(m)
l = []
for i in range(n):
	s1 = input('')
	l.append(list(s1))
l1 = []
for i in range(n):
	temp = l[i].count('S')
	if temp == 0:
		for j in range(m):
			l1.append([i, j])
l2 = list(map(list, zip(*l)))
for i in range(m):
	temp = l2[i].count('S')
	if temp == 0:
		for j in range(n):
			l1.append([j, i])
l3 = []
count = 0
for i in l1:
	if i not in l3:
		l3.append(i)
print(len(l3))


(r, c) = map(int, input().split())
cake = []
eat = r * c
rows = set()
cols = set()
for i in range(r):
	cake.append([i for i in input()])
	for (j, char) in enumerate(cake[i]):
		if char == 'S':
			rows.add(i)
			cols.add(j)
print(eat - len(rows) * len(cols))


(n, m) = map(int, input().split())
s = ''
sm = 0
for _ in range(n):
	temp = input().strip()
	if 'S' in temp:
		s += temp
	else:
		sm += len(temp)
		n -= 1
for i in range(m):
	sm += ('S' not in s[i::m]) * n
print(sm)


(h, w) = map(int, input().split())
(can_collums, can_rows) = ([True for i in range(w)], [True for i in range(h)])
cake = []
for row_i in range(h):
	line = input()
	row = []
	for (collum_i, c) in enumerate(line):
		if c == 'S':
			row.append(1)
			can_collums[collum_i] = False
			can_rows[row_i] = False
		else:
			row.append(0)
	cake.append(row)
can = 0
for (row_i, row) in enumerate(cake):
	can_row = can_rows[row_i]
	for (collum_i, collum) in enumerate(row):
		can_collum = can_collums[collum_i]
		if can_row or can_collum:
			can += 1
print(can)


(n, m) = map(int, input().split())
arr = []
mapping = {}
x = []
y = []
ans = 0
for _ in range(n):
	line = input()
	for i in range(m):
		if line[i] == 'S':
			x.append(_)
			y.append(i)
for i in range(n):
	for j in range(m):
		if i in x and j in y:
			continue
		else:
			ans += 1
print(ans)


(n, m) = map(int, input().split())
r = []
c = []
t = 0
d = 0
for i in range(n):
	a = list(input())
	for j in range(m):
		if a[j] == 'S':
			r.append(i)
			c.append(j)
	a = []
for i in range(n):
	if i not in r:
		t += m
		d += 1
for i in range(m):
	if i not in c:
		t += n - d
print(t)


(r, c) = map(int, input().split())
(rs, cs) = (set(), set())
M = []
for i in range(r):
	a = input()
	for j in range(len(a)):
		if a[j] == 'S':
			cs.add(j)
			rs.add(i)
	M += [a]
an = 0
for i in range(r):
	for j in range(c):
		if M[i][j] == '.' and (i not in rs or j not in cs):
			an += 1
print(an)


(r, c) = map(int, input().split())
cake = []
for i in range(r):
	cake.append(list(input()))
cake_transposed = list(zip(*cake))
count = 0
for i in range(r):
	for j in range(c):
		if 'S' not in cake[i] or 'S' not in cake_transposed[j]:
			count = count + 1
print(count)


def solve(r, c, cake):
	col = list()
	for i in range(0, c):
		isColEdible = True
		isOneCakeAvailable = False
		for j in range(0, r):
			if cake[j][i] == '.':
				isOneCakeAvailable = True
			elif cake[j][i] == 'S':
				isColEdible = False
		if isOneCakeAvailable and isColEdible:
			col.append(i)
	row = list()
	allRowsEdibleCount = 0
	for i in range(0, r):
		thisRowEdibleCount = 0
		isRowEdible = True
		isOneCakeAvailable = False
		for j in range(0, c):
			if cake[i][j] == '.' and j not in col:
				isOneCakeAvailable = True
				thisRowEdibleCount += 1
			elif cake[i][j] == 'S':
				isRowEdible = False
		if isOneCakeAvailable and isRowEdible:
			row.append(i)
			allRowsEdibleCount += thisRowEdibleCount
	return len(col) * r + allRowsEdibleCount
(r, c) = map(int, input().split(' '))
cake = list()
_r = 0
while _r < r:
	cake_line = list()
	cake_line = input()
	cake.append(cake_line)
	_r += 1
print(solve(r, c, cake))


data = input().split()
(R, C) = (int(data[0]), int(data[1]))
cake = [[None] * C] * R
for i in range(R):
	cake[i] = input()
eaten_cake = 0
for i in range(R):
	if cake[i].count('S') == 0:
		eaten_cake += C
		cake[i] = '1' * C
		continue
for j in range(C):
	S_flag = 0
	for i in range(R):
		if cake[i][j] == 'S':
			S_flag = 1
			break
	if S_flag == 1:
		continue
	else:
		for i in range(R):
			if cake[i][j] == '.':
				eaten_cake += 1
print(eaten_cake)


import sys
(r, c) = map(int, sys.stdin.readline().split())
cake = []
for i in range(0, r):
	cake.append(input())
good_raws = r
good_columns = c
for i in range(0, r):
	k_raws = 0
	for j in range(0, c):
		if cake[i][j] == 'S':
			k_raws = 1
	if k_raws == 1:
		good_raws -= 1
rows_eaten_cells = good_raws * c
for j in range(0, c):
	k_columns = 0
	for i in range(0, r):
		if cake[i][j] == 'S':
			k_columns = 1
	if k_columns == 1:
		good_columns -= 1
columns_eaten_cells = good_columns * (r - good_raws)
print(rows_eaten_cells + columns_eaten_cells)


(n, m) = list(map(int, input().split()))
s = []
a = [True] * (n + 1)
b = [True] * (m + 1)
for i in range(n):
	s.append(input())
x = 0
for i in range(n):
	for j in range(m):
		if s[i][j] == 'S':
			a[i] = False
			b[j] = False
for i in range(n):
	for j in range(m):
		if a[i] or b[j]:
			x += 1
print(x)


(num_rows, num_columns) = map(int, input().split())
non_empty_rows = set()
non_empty_cols = set()
for num_row in range(1, num_rows + 1):
	row = input()
	for (num_column, char) in enumerate(row, start=1):
		if char == 'S':
			non_empty_rows.add(num_row)
			non_empty_cols.add(num_column)
num_empty_rows = num_rows - len(non_empty_rows)
num_empty_cols = num_columns - len(non_empty_cols)
print(num_empty_rows * num_columns + num_empty_cols * num_rows - num_empty_cols * num_empty_rows)


grid = []
size = input().split(' ')
rows = int(size[0])
columns = int(size[1])
for t in range(rows):
	grid.append(input())
rs = 0
for element in grid:
	if 'S' in element:
		rs += 1
clms = 0
for clmn in range(columns):
	sa = 0
	for element in grid:
		if element[clmn] == 'S':
			sa = 1
	if sa == 1:
		clms += 1
print(rows * columns - rs * clms)


(r, c) = map(int, input().split())
cell = [input() for i in range(r)]
rows = []
cols = []
for i in range(r):
	for j in range(c):
		if cell[i][j] == 'S':
			rows.append(i)
			cols.append(j)
print(r * c - len(set(rows)) * len(set(cols)))


(n, m) = map(int, input().split())
ans1 = 0
ans2 = 0
l = [['0' for f1 in range(m)] for f2 in range(n)]
for f1 in range(n):
	s = input()
	for f2 in range(m):
		l[f1][f2] = s[f2]
for f1 in range(n):
	ans1 += m
	for f2 in range(m):
		if l[f1][f2] != '.':
			ans1 -= m
			break
for f1 in range(m):
	ans2 += n - ans1 / m
	for f2 in range(n):
		if l[f2][f1] != '.':
			ans2 -= n - ans1 / m
			break
print(int(ans1 + ans2))


(row, col) = map(int, input().split())
tab = [[i for i in input()] for j in range(row)]
num_row = num_col = 0
tab_2 = []
for (ind, i) in enumerate(tab):
	if 'S' not in i:
		num_row += len(i)
	else:
		tab_2.append(i)
tmp = 0
if len(tab_2) == 0:
	print(num_row)
else:
	for i in range(len(tab_2[0])):
		if tmp == 1:
			num_col += len(tab_2)
		tmp = 0
		for j in range(len(tab_2)):
			if tab_2[j][i] == 'S':
				tmp = 0
				break
			tmp = 1
	if tmp == 1:
		num_col += len(tab_2)
	print(num_row + num_col)


(a, b) = map(int, input().split())
l = []
for i in range(a):
	l.append(input())
for i in range(a):
	c = 0
	for j in range(b):
		if l[i][j] != 'S':
			c += 1
	if b - c == 0:
		for n in range(len(l[i])):
			l[i] = '*' * b
for j in range(b):
	c = 0
	for i in range(a):
		if l[i][j] != 'S':
			c += 1
	if a - c == 0:
		for w in range(a):
			s = list(l[w])
			s[j] = '*'
			l[w] = ''.join(s)
c = 0
for i in range(a):
	c += l[i].count('*')
print(c)


(r, c) = map(int, input().split())
rt = [0] * 10
ct = [0] * 10
for i in range(r):
	s = str(input())
	for j in range(len(s)):
		if s[j] == 'S':
			rt[i] = 1
			ct[j] = 1
cnt = 0
for i in range(r):
	for j in range(c):
		if rt[i] == 0 or ct[j] == 0:
			cnt += 1
print(cnt)


(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)


(n, m) = list(map(int, input().split()))
l = []
r = []
c = [1 for i in range(m)]
f = 0
for i in range(n):
	s = input()
	l.append([i for i in s])
	if 'S' in s:
		for j in range(m):
			if s[j] == 'S':
				c[j] = 0
		f = 1
	else:
		r.append(i)
if f == 0:
	print(m * n)
else:
	ans = 0
	for i in range(m):
		if c[i] == 1:
			for j in range(n):
				l[j][i] = '0'
			ans += n
	for i in r:
		for j in range(m):
			if l[i][j] == '.':
				ans += 1
	print(ans)


(r, c) = map(int, input().split())
m = []
a = []
for i in range(r):
	s = input()
	a.append(s)
for i in range(r):
	if 'S' not in a[i]:
		m.extend([(i, j) for j in range(c)])
for i in range(c):
	b = []
	for j in range(r):
		b.append(a[j][i])
	if 'S' not in b:
		m.extend([(k, i) for k in range(r)])
m = set(m)
print(len(m))


(n, m) = map(int, input().split())
x = [input() for i in range(n)]
cnt1 = 0
cnt2 = 0
row = 0
col = 0
for i in range(n):
	row = 0
	for j in range(m):
		if x[i][j] == 'S':
			break
		else:
			row += 1
	if row == m:
		cnt1 += 1
for i in range(m):
	col = 0
	for j in range(n):
		if x[j][i] == 'S':
			break
		else:
			col += 1
	if col == n:
		cnt2 += 1
print(cnt1 * m + cnt2 * n - cnt1 * cnt2)


(r, c) = map(int, input().split())
rlist = []
clist = []
cake = []
for x in range(r):
	cake.append(input())
	for y in range(c):
		if cake[x][y] == 'S':
			rlist.append(x)
			clist.append(y)
(count, cek) = (0, 0)
for x in range(r):
	if x not in rlist:
		count += c
		cek += 1
for x in range(c):
	if x not in clist:
		count += r
		count -= cek
print(count)


(r, c) = map(int, input().split(' '))
board = []
for i in range(r):
	board.append(list(input()))
eaten = 0
for i in range(r):
	ghosts = 0
	for j in range(c):
		if board[i][j] == 'S':
			ghosts += 1
	if ghosts == 0:
		for j in range(c):
			if board[i][j] == '.':
				eaten += 1
				board[i][j] = '0'
for j in range(c):
	ghosts = 0
	for i in range(r):
		if board[i][j] == 'S':
			ghosts += 1
	if ghosts == 0:
		for i in range(r):
			if board[i][j] == '.':
				eaten += 1
				board[i][j] = '0'
print(eaten)


(H, W) = [int(x) for x in input().split()]
A = []
ateHoris = 0
ateSum = 0
for y in range(H):
	A.append([])
	A[y] = input()
	berry = 0
	for x in A[y]:
		if x == 'S':
			berry = 1
	if not berry:
		ateHoris += 1
		ateSum += W
for x in range(W):
	berry = 0
	for y in range(H):
		if A[y][x] == 'S':
			berry = 1
	if not berry:
		ateSum += H - ateHoris
print(ateSum)


(r, c) = map(int, input().split())
(horiz, vert) = ([], [])
for i in range(r):
	horiz.append([])
for i in range(c):
	vert.append([])
for i in range(r):
	s = input()
	for j in range(c):
		horiz[i].append(s[j])
		vert[j].append(s[j])
ans = r * c
for i in range(r):
	for j in range(c):
		if 'S' in horiz[i] and 'S' in vert[j]:
			ans -= 1
print(ans)


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())
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)


nums = input().split()
mainlst = []
pieces = 0
for i in range(int(nums[0])):
	a = list(input())
	mainlst.append(a)
mainlst2 = []
for i in mainlst:
	if 'S' not in i:
		pieces += len(i)
	else:
		mainlst2.append(i)
new_lst = list(zip(*mainlst2))
for i in new_lst:
	if 'S' not in i:
		pieces += len(i)
print(pieces)


(r, c) = map(int, input().split(' '))
list1 = []
for j in range(r):
	list1.append(list(input()))
sum1 = 0
for j in range(c):
	stri = ''
	for i in range(r):
		stri += list1[i][j]
	if 'S' not in stri:
		sum1 += len(stri)
		for i in range(r):
			list1[i][j] = '*'
for j in list1:
	if 'S' not in j:
		sum1 += j.count('.')
print(sum1)


(r, c) = [int(i) for i in input().split()]
strings = []
for _ in range(r):
	strings.append(input())
rows = [-1 for _ in range(r)]
cols = [-1 for _ in range(c)]
for i in range(r):
	for j in range(c):
		if strings[i][j] == 'S':
			rows[i] = cols[j] = 1
count = 0
for i in range(r):
	for j in range(c):
		if rows[i] != 1 or cols[j] != 1:
			count += 1
print(count)


(n, m) = map(int, input().split())
s = [list(input()) for i in range(n)]
r1 = len([1 for i in s if 'S' in i])
r2 = len([1 for i in zip(*s) if 'S' in i])
print(n * m - r1 * r2)


(n, m) = map(int, input().split())
cake = [[i for i in input()] for _ in range(n)]
count = 0
for i in range(n):
	for j in range(m):
		if cake[i][j] == '.':
			for i_mod in range(n):
				if cake[i_mod][j] == 'S':
					S_not_in_column = False
					break
			else:
				S_not_in_column = True
			if cake[i].count('S') == 0 or S_not_in_column:
				count += 1
print(count)


i = input().split()
(r, c) = (int(i[0]), int(i[1]))
cake = []
index = []
total = 0
for i in range(r):
	row = input()
	row = [x for x in row]
	if 'S' not in row:
		index.append([0] * c)
		total += c
	else:
		index.append([1] * c)
	cake.append(row)
for i in range(c):
	for j in range(r):
		if cake[j][i] == 'S':
			break
	else:
		for j in range(r):
			if index[j][i] == 1:
				total += 1
print(total)


(r, c) = map(int, input().split())
a = []
o = 0
for i in range(r):
	b = input()
	a.append(b)
	if not 'S' in b:
		o += len(a.pop())
	else:
		continue
for i in range(c):
	d = 0
	for j in range(len(a)):
		if a[j][i] == 'S':
			d = 0
			break
		else:
			d += 1
	o += d
print(o)


(r, c) = map(int, input().split())
rows = set()
col = set()
for i in range(r):
	x = input()
	for j in range(c):
		if x[j] == 'S':
			rows.add(i)
			col.add(j)
print(r * c - len(rows) * len(col))


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


(r, c) = map(int, input().split())
mapa = []
linha = 0
coluna = 0
for i in range(r):
	mapa.append(input())
for i in range(r):
	if mapa[i].find('S') < 0:
		linha += c
mapa = list(zip(*mapa))
for i in range(c):
	if ''.join(mapa[i]).find('S') < 0:
		coluna += r - linha // c
print(linha + coluna)


(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)


(n, m) = input().split()
n = int(n)
m = int(m)
a = []
s = []
for i in range(n):
	s = input()
	a.append(s)
c = 0
for i in range(m):
	lc = 0
	clear = True
	for j in range(n):
		if a[j][i] == 'S':
			clear = False
			break
		elif a[j][i] == '.':
			lc += 1
	if clear:
		t = []
		for j in range(n):
			a[j] = a[j][:i] + ' ' + a[j][i + 1:]
		c += lc
for i in range(n):
	lc = 0
	clear = True
	for j in range(m):
		if a[i][j] == 'S':
			clear = False
			break
		elif a[i][j] == '.':
			lc += 1
	if clear:
		a[i] = m * ' '
		c += lc
print(c)


inp = list(map(int, input().split()))
(r, c) = inp
arr = []
for _ in range(r):
	s = input()
	arr.append(s)
from collections import Counter
row = Counter([])
col = Counter([])
for i in range(len(arr)):
	for j in range(len(arr[i])):
		if arr[i][j] == 'S':
			row[i] += 1
			col[j] += 1
ans = 0
for i in range(len(arr)):
	for j in range(len(arr[i])):
		if row[i] != 0 and col[j] != 0:
			ans += 1
print(r * c - ans)


a = []
a = input().split()
r = int(a[0])
c = int(a[1])
s = []
for i in range(0, r):
	s.append(input())
row = []
p = 0
for i in range(0, r):
	count = 0
	for j in range(0, c):
		if s[i][j] == '.':
			count += 1
	if count == c:
		p += c
		row.append(i)
col = []
for i in range(0, r):
	if row.count(i) == 0:
		col.append(s[i])
for i in range(0, c):
	count = 0
	for j in range(0, len(col)):
		if col[j][i] == '.':
			count += 1
	if count == len(col):
		p += len(col)
print(p)


(n, m) = map(int, input().split())
a = []
count = 0
for i in range(n):
	a.append(list(map(str, input().split())))
for i in range(n):
	if 'S' in a[i][0]:
		continue
	else:
		count += m
		a[i][0] = '#' * m
for i in range(m):
	b = []
	for j in range(n):
		b.append(a[j][0][i])
	if 'S' in b:
		continue
	else:
		count += b.count('.')
print(count)


def cakeMinator(cake):
	ans = int()
	cols = int()
	for i in range(len(cake[0])):
		for j in range(len(cake)):
			if cake[j][i] == 'S':
				break
		else:
			ans += len(cake)
			cols += 1
	for i in range(len(cake)):
		for j in range(len(cake[0])):
			if cake[i][j] == 'S':
				break
		else:
			ans += len(cake[0]) - cols
	return ans
rc = [int(i) for i in input().split()]
r = rc[0]
c = rc[1]
cake = list()
for i in range(r):
	row = [i for i in input()]
	cake.append(row)
print(cakeMinator(cake))


import sys
from functools import reduce
from collections import Counter
import time
import datetime
from math import sqrt, gcd

def ip():
	return int(sys.stdin.readline())

def sip():
	return sys.stdin.readline()

def mip():
	return map(int, sys.stdin.readline().split())

def mips():
	return map(str, sys.stdin.readline().split())

def lip():
	return list(map(int, sys.stdin.readline().split()))

def matip(n, m):
	lst = []
	for i in range(n):
		arr = lip()
		lst.append(arr)
	return lst

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def minJumps(arr, n):
	jumps = [0 for i in range(n)]
	if n == 0 or arr[0] == 0:
		return float('inf')
	jumps[0] = 0
	for i in range(1, n):
		jumps[i] = float('inf')
		for j in range(i):
			if i <= j + arr[j] and jumps[j] != float('inf'):
				jumps[i] = min(jumps[i], jumps[j] + 1)
				break
	return jumps[n - 1]

def dic(arr):
	return Counter(arr)

def check_prime(n):
	if n < 2:
		return False
	for i in range(2, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True
(n, m) = mip()
arr = []
val = 0
for i in range(n):
	s = sip()
	lst = []
	for j in range(m):
		lst.append(s[j])
	arr.append(lst)
i = 0
while i < n:
	if arr[i].count('S') == 0:
		val += m
		arr.pop(i)
		n -= 1
	else:
		i += 1
for i in range(m):
	flag = 0
	for j in range(n):
		if arr[j][i] == 'S':
			flag = 1
	if flag == 0:
		val += n
print(val)


import sys
inf = float('inf')
(mod, MOD) = (1000000007, 998244353)

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()))
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
		if flag == 0:
			for k in range(n):
				visited[k][j] = 1
		flag = 0
		for k in range(m):
			if mat[i][k] == 'S':
				flag = 1
		if flag == 0:
			for k in range(m):
				visited[i][k] = 1
ans = 0
for i in visited:
	ans += i.count(1)
print(ans)


def R():
	return map(int, input().split())

def I():
	return int(input())

def S():
	return str(input())

def L():
	return list(R())
from collections import Counter
import math
import sys
from itertools import permutations
import bisect
(n, m) = R()
s = [''] * n
for i in range(n):
	s[i] = S()
r = set()
c = set()
for i in range(n):
	for j in range(m):
		if s[i][j] == 'S':
			r.add(i)
			c.add(j)
print((n - len(r)) * m + (m - len(c)) * n - (n - len(r)) * (m - len(c)))


import sys
input = sys.stdin.readline

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 = list()
for i in range(r):
	a.append(input())
x = 0
k = 0
h = 0
for i in range(r):
	for j in range(c):
		if a[i][j] == 'S':
			x = 1
			break
	if x:
		x = 0
	else:
		k += c
		h += 1
x = 0
for i in range(c):
	for j in range(r):
		if a[j][i] == 'S':
			x = 1
			break
	if x:
		x = 0
	else:
		k += r - h
print(k)


(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())
l = []
c1 = 0
x = 0
for i in range(r):
	l1 = list(input())
	if 'S' not in l1:
		c1 += c
		x += 1
		pass
	else:
		l.append(l1)
r -= x
for i in range(c):
	c2 = 0
	for j in range(r):
		if l[j][i] == '.':
			c2 += 1
		else:
			c2 = 0
			break
	c1 += c2
print(c1)


(r, c) = map(int, input().split())
l = []
for _ in range(r):
	l1 = list(input())
	l.append(l1)
to = 0
e = 0
for i in l:
	if 'S' not in i:
		to += c
		e += 1
for i in range(c):
	no = 0
	for j in range(r):
		if l[j][i] == 'S':
			no += 1
			break
	if no == 0:
		to += r - e
print(to)


def inp():
	return map(int, input().split())
(r, c) = inp()
(arr, out) = ([], 0)
for i in range(r):
	s = input()
	if s.count('S') != 0:
		arr.append(s)
	else:
		out += c
for i in range(c):
	sum = 0
	for j in range(len(arr)):
		if arr[j][i] != 'S':
			sum += 1
		else:
			break
		if sum == len(arr):
			out += sum
print(out)


(r, c) = list(map(int, input().split()))
s = 0
ch = [[] for i in range(c)]
for i in range(r):
	z = input()
	if z == c * '.':
		s += c
	else:
		for ii in range(c):
			ch[ii].append(z[ii])
for i in ch:
	if i == ['.'] * len(i):
		s += len(i)
print(s)


def solve(r, c, m):
	t = 0
	for i in range(r):
		if m[i].count('.') == c:
			m[i] = 'c' * c
			t += c
	for j in range(c):
		x = 0
		for i in range(r):
			if m[i][j] == '.' or m[i][j] == 'c':
				x += 1
		if x == r:
			for i in range(r):
				if m[i][j] == '.':
					m[i][j] = 'c'
					t += 1
	return t

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


(n, k) = [int(x) for x in input().split()]
table = []
for _ in range(n):
	table.append(list(input()))
for i in range(n):
	if 'S' not in table[i]:
		table[i] = ['e'] * len(table[i])
		attempt = True
for j in range(k):
	rem = True
	for i in range(n):
		if table[i][j] == 'S':
			rem = False
	if rem:
		for i in range(n):
			table[i][j] = 'e'
print(''.join([''.join(x) for x in table]).count('e'))


num = input()
a = []

def get_the_data(count, num, arr):
	for i in range(0, len(num)):
		if num[i] == ' ':
			arr.append(int(num[count:i]))
			count = i + 1
		elif i == len(num) - 1:
			arr.append(int(num[count:len(num)]))
	return arr
arr = get_the_data(0, num, a)
n = a[0]
i = 0
data = list()
while i < n:
	data.append(input())
	i += 1
mix = [[False] * len(data[0]) for _ in range(len(data))]
count = 0
for i in range(0, len(data)):
	check = False
	for j in range(0, len(data[i])):
		if data[i][j] == 'S':
			check = True
			break
	if check == False:
		for j in range(0, len(data[i])):
			mix[i][j] = True
		count += len(data[i])
for i in range(len(data[0])):
	check = False
	for j in data:
		if j[i] == 'S':
			check = True
			break
	if check == False:
		for j in range(len(data)):
			if mix[j][i] == False:
				count += 1
print(count)


(n, m) = map(int, input().split())
b = [list((i for i in input())) for j in range(n)]
say = 0
for i in range(n):
	if 'S' not in b[i]:
		for j in range(m):
			if b[i][j] == '.':
				say += 1
				b[i][j] = ','
d = []
for i in range(m):
	a = []
	for j in range(n):
		a.append(b[j][i])
	d.append(a)
for i in range(m):
	if 'S' not in d[i]:
		for j in range(n):
			if d[i][j] == '.':
				say += 1
				d[i][j] = ','
print(say)


(n, m) = map(int, input().split())
a = []
for i in range(n):
	a.append(list(input()))
for i in range(n):
	ok = 1
	for j in range(m):
		if a[i][j] == 'S':
			ok = 0
	if ok:
		for j in range(m):
			a[i][j] = '+'
for j in range(m):
	ok = 1
	for i in range(n):
		if a[i][j] == 'S':
			ok = 0
	if ok:
		for i in range(n):
			a[i][j] = '+'
o = 0
for i in range(n):
	for j in range(m):
		if a[i][j] == '+':
			o += 1
print(o)


import math
from collections import defaultdict, Counter, deque
INF = float('inf')

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def primeFactor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i ** 2 <= n:
		if n % i == 0:
			return i
		i += 1
	return n

def main():
	(n, m) = map(int, input().split())
	mat = []
	for i in range(n):
		mat.append(input())
	ans = 0
	e = defaultdict(int)
	for i in range(n):
		eaten = 0
		if 'S' not in mat[i]:
			for j in range(m):
				e[i, j] = 1
				eaten += 1
			ans += eaten
	for j in range(m):
		eaten = 0
		isS = False
		for i in range(n):
			if mat[i][j] == 'S':
				isS = True
				break
		if not isS:
			for i in range(n):
				if e[i, j] == 0:
					e[i] = 1
					eaten += 1
			ans += eaten
	print(ans)
t = 1
for _ in range(t):
	main()


(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))


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


(n, m) = [int(i) for i in input().split()]
cake = []
eatenBlocks = 0
eatenRows = 0
for k in range(0, n):
	cake.append(input())
	if 'S' not in cake[k]:
		eatenBlocks += m
		eatenRows += 1
for j in range(0, m):
	canEat = False
	for i in range(0, n):
		if cake[i][j] != 'S':
			canEat = True
		else:
			canEat = False
			break
	if canEat == True:
		eatenBlocks += n - eatenRows
		canEat = False
print(eatenBlocks)


(n, m) = map(int, input().split())
b = []
for t in range(n):
	a = input()
	s = [char for char in a]
	b.append(s)
i = 0
j = 0
while i < n:
	while j < m:
		if b[i][j] == 'S':
			break
		if j + 1 == m:
			j = 0
			while j < m:
				b[i][j] = 'X'
				j += 1
		j += 1
	j = 0
	i += 1
i = 0
j = 0
while j < m:
	while i < n:
		if b[i][j] == 'S':
			break
		if i + 1 == n:
			i = 0
			while i < n:
				b[i][j] = 'X'
				i += 1
		i += 1
	i = 0
	j += 1
total = 0
for c in range(len(b)):
	for l in range(len(b[c])):
		if b[c][l] == 'X':
			total += 1
print(total)


(r, c) = (int(i) for i in input().split())
cols = set()
rows = 0
for i in range(r):
	s = list(input())
	if 'S' in s:
		rows += 1
		while 'S' in s:
			cols.add(s.index('S') + 1)
			s[s.index('S')] = '.'
print(r * c - rows * len(cols))


(n, m) = map(int, input().split())
a = []
c = 0
for i in range(n):
	s = input()
	s = s.replace('S', '0')
	s = s.replace('.', '1')
	b = list(s)
	a.append(b)
	if s.count('1') == m:
		c += 1
count = c * m
for i in range(m):
	z = 0
	for j in range(n):
		if a[j][i] == '1':
			z += 1
		else:
			z = 0
			break
	if z != 0:
		count += z - c
print(count)


num = input()
nums = num.split()
num_row = int(nums[0])
num_col = int(nums[1])
rows_evil = {}
cols_evil = {}
num_evil = 0
for i in range(0, num_row):
	row = input()
	for k in range(0, len(row)):
		if row[k] == 'S':
			cols_evil[k] = 1
			rows_evil[i] = 1
cake = (num_row - len(rows_evil)) * num_col
cake += (num_col - len(cols_evil)) * len(rows_evil)
print(cake)


(r, c) = map(int, input().split())
s = set()
cood = []
virtuel = set()
for i in range(r):
	l = input()
	for j in range(c):
		if l[j] == 'S':
			s.add((i + 1, j + 1))
			cood.append(j + 1)
for element in s:
	for co in cood:
		virtuel.add((element[0], co))
print(r * c - len(s | virtuel))


(r, c) = map(int, input().split())
l = [input() for _ in range(r)]
(count, share) = (0, 0)
temp = []
for i in l:
	if '.' * c in i:
		count += 1 * c
		share += 1
for j in range(c):
	temp = []
	for i in range(r):
		if l[i][j] == 'S':
			temp = []
			break
		else:
			temp.append(l[i][j])
	if temp:
		count += 1 * r - share
print(count)


(n, m) = map(int, input().split())
a = ['' for i in range(m)]
cnt = 0
for i in range(n):
	s = input()
	if 'S' not in s:
		cnt += m
		s = '*' * m
	for j in range(m):
		a[j] += s[j]
for i in range(m):
	s = a[i]
	if 'S' not in s:
		b = s.count('.')
		cnt += b
print(cnt)


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


z = list(map(int, input().split()))
n = z[0]
m = z[1]
arr = []
for i in range(n):
	arr += [[' '] * m]
	x = input()
	for j in range(m):
		arr[i][j] = x[j]
count = 0
status = 0
for i in range(n):
	for j in range(m):
		if arr[i][j] == '.' or arr[i][j] == ',':
			if arr[i][j] == '.':
				status += 1
		else:
			status = 0
			break
	if status != 0:
		count += status
		status = 0
		for j in range(m):
			arr[i][j] = ','
status = 0
for i in range(m):
	for j in range(n):
		if arr[j][i] == '.' or arr[j][i] == ',':
			if arr[j][i] == '.':
				status += 1
		else:
			status = 0
			break
	if status != 0:
		count += status
		status = 0
		for j in range(n):
			arr[j][i] == ','
print(count)


(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 count(arr, rows, columns, r, c):
	for row in range(r):
		if row not in rows:
			arr[row] = ['e'] * c
	for col in range(c):
		if col not in columns:
			for row in range(r):
				arr[row][col] = 'e'
	return arr
arr = list(map(int, input().rstrip().split()))
r = arr[0]
c = arr[1]
arr = []
rows = []
columns = []
for i in range(r):
	temp = list(input().rstrip())
	arr.append(temp)
	if 'S' in temp:
		rows.append(i)
		index = temp.index('S')
		while True:
			columns.append(index)
			temp = arr[i][index + 1:]
			if 'S' not in temp:
				break
			else:
				index += temp.index('S') + 1
total = 0
arr = count(arr, rows, columns, r, c)
for i in range(r):
	for j in range(c):
		if arr[i][j] == 'e':
			total += 1
print(total)


(n, m) = map(int, input().split())
countern = [0] * n
counterm = [0] * m
for i in range(n):
	x = input()
	for j in range(m):
		if x[j] == 'S':
			countern[i] = 1
			counterm[j] = 1
sumn = 0
for i in range(n):
	sumn += countern[i]
summ = 0
for i in range(m):
	summ += counterm[i]
print(n * m - sumn * summ)


(r, c) = map(int, input().split())
h = []
v = []
for i in range(r):
	x = list(input())
	for j in range(c):
		if x[j] == 'S':
			h.append(i)
			v.append(j)
ans = r * c - len(list(set(h))) * len(list(set(v)))
print(ans)


(r, c) = map(int, input().split())
cake = []
for i in range(r):
	cake.append(list(input()))
i = 0
count = 0
while i < r:
	if not 'S' in cake[i]:
		r -= 1
		count += c
		del cake[i]
	else:
		i += 1
for x in range(c):
	col = [cake[z][x] for z in range(r)]
	if not 'S' in col:
		count += r
print(count)


(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))


(r, c) = [int(x) for x in input().split()]
cake = []
for i in range(0, r):
	cake.append(input())
number = 0
notrows = 0
for row in cake:
	if 'S' not in row:
		number += c
		notrows += 1
for column in range(0, c):
	find = False
	for row in cake:
		if row[column] == 'S':
			find = True
	if not find:
		number += r - notrows
print(number)


(r, c) = map(int, input().split())
b = [r for i in range(c)]
(count, x) = (0, 0)
for i in range(r):
	a = input()
	if 'S' not in a:
		count += c
		x += 1
	else:
		for j in range(c):
			if a[j] == 'S':
				b[j] -= 1
for i in b:
	if i == r:
		count = count + i - x
print(count)


(r, c) = map(int, input().split())
(row, col) = (set(), set())
for i in range(r):
	a = input()
	for j in range(c):
		if a[j] == 'S':
			row.add(i)
			col.add(j)
n = r - len(row)
m = c - len(col)
print(n * c + m * r - n * m)


(m, n) = [int(x) for x in input().split()]
row = 0
arr = []
for i in range(m):
	x = input()
	if x.count('S') == 0:
		row += 1
	else:
		for j in range(n):
			if x[j] == 'S':
				arr.append(j)
col = n - len(set(arr))
print(row * n + col * m - row * col)


(r, c) = [int(i) for i in input().split()]
matrix = []
res = 0
for _ in range(r):
	matrix.append(input())
for i in range(r - 1, -1, -1):
	if 'S' in list(matrix[i]):
		continue
	else:
		res += len(matrix[i])
		del matrix[i]
for tup in zip(*matrix):
	if 'S' in tup:
		continue
	else:
		res += len(tup)
print(res)


a = [int(i) for i in filter(None, input().split(' '))]
arr = []
for i in range(a[0]):
	arr += [i for i in filter(None, input().split(' '))]
stolb = []
str = []
for i in range(a[0]):
	for j in range(a[1]):
		if arr[i][j] == 'S':
			if not i in str:
				str.append(i)
			if not j in stolb:
				stolb.append(j)
k_str = len(str)
k_stolb = len(stolb)
ans = a[0] * a[1] - k_stolb * k_str
print(ans)


(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 = input().split(' ')
cake = []
count = 0
for i in range(int(n[0])):
	row = list(input())
	cake.append(row)
for i in cake:
	if 'S' not in i:
		count += len(i)
		for j in range(len(i)):
			i[j] = 0
berry = False
for j in range(len(cake[0])):
	for k in range(len(cake)):
		if cake[k][j] == 'S':
			berry = True
			break
	if not berry:
		for k in range(len(cake)):
			if cake[k][j] == '.':
				count += 1
	berry = False
print(count)


(r, c) = map(int, input().split())
count = 0
rows = set()
cols = set()
for i in range(r):
	s = input().strip()
	for j in range(c):
		if s[j] == 'S':
			cols.add(j)
			rows.add(i)
print(r * c - len(rows) * len(cols))


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


(r, c) = map(int, input().split())
a = []
ans = 0
counter = r
s = input()
if s.find('S') == -1:
	ans += c
	counter -= 1
	a = [i for i in range(c)]
else:
	for j in range(c):
		if s[j] != 'S':
			a.append(j)
for i in range(r - 1):
	s = input()
	if s.find('S') == -1:
		ans += c
		counter -= 1
	else:
		for i in range(len(a)):
			if s[a[i]] == 'S':
				a[i] = -1
for i in range(len(a)):
	if a[i] != -1:
		ans += counter
print(ans)


(m, n) = list(map(int, input().split(' ')))
inputList = []
strawberryPosRow = []
strawberryPosCol = []
for row in range(m):
	ch = input()
	inputList.append(ch)
for i in range(len(inputList)):
	for j in range(n):
		if inputList[i][j] == 'S':
			strawberryPosRow.append(i)
			strawberryPosCol.append(j)
r = len(set(strawberryPosRow))
c = len(set(strawberryPosCol))
print(m * n - r * c)


(r, c) = list(map(int, input().split()))
no_r = 0
a = []
res = 0
for _ in range(r):
	s = input()
	a.append(s)
	if 'S' not in s:
		no_r += 1
for i in range(c):
	has_s = False
	for j in range(r):
		if a[j][i] == 'S':
			has_s = True
			break
	if not has_s:
		res += r - no_r
res += no_r * c
print(res)


(r, c) = map(int, input().split())
l = []
for _ in range(r):
	s = input()
	l.append(s)
a = []
b = []
z = 0
for x in range(r):
	for y in range(c):
		if l[x][y] == 'S':
			a.append(x)
			b.append(y)
for i in range(r):
	for j in range(c):
		if i in a and j in b:
			z += 0
		else:
			z += 1
print(z)


(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)


(r, c) = [int(z) for z in input().split()]
r1 = list(range(0, r))
c1 = list(range(0, c))
for i in range(0, r):
	s = input()
	for j in range(0, len(s)):
		if s[j] == 'S':
			if i in r1:
				r1.remove(i)
			if j in c1:
				c1.remove(j)
print(len(r1) * c + len(c1) * r - len(r1) * len(c1))


(n, m) = map(int, input().split())
full = [0] * n
count = add = 0
for i in range(n):
	full[i] = '-'.join(input()).split('-')
	for j in range(m):
		if full[i][j] == 'S':
			full[i][j] = 2
		else:
			full[i][j] = 1
for i in range(n):
	if full[i].count(2) > 0:
		continue
	else:
		for j in range(m):
			if full[i][j] == 1:
				full[i][j] = 0
				count += 1
for i in range(m):
	for j in range(n):
		backup = full[j][i]
		full[j][i] = '+'
		full[j][i] = backup
		if full[j][i] == 2:
			add = 0
			break
		if j == n - 1:
			for j in range(n):
				backup = full[j][i]
				full[j][i] = '+'
				full[j][i] = backup
				if full[j][i] == 1:
					full[j][i] = 0
					count += 1
print(count)


(r, c) = map(int, input().split())
(S_rows, S_columns) = (set(), set())
for i in range(r):
	for (j, cell) in enumerate(input()):
		if cell == 'S':
			S_rows.add(i)
			S_columns.add(j)
print(r * c - len(S_rows) * len(S_columns))


(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)


(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)


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


(r, c) = map(int, input('').split())
l = list()
summ = 0
for i in range(r):
	l.append(input())
	if 'S' not in l[i]:
		summ += 1
flag = False
sumhor = 0
for i in range(c):
	for j in range(r):
		if l[j][i] == 'S':
			flag = True
			break
	if flag == False:
		sumhor += 1
	flag = False
print(summ * c + (sumhor * r - summ * sumhor))


(r, c) = [int(i) for i in input().split()]
arr = []
k = 0
r2 = r
for i in range(r):
	a = input()
	arr.append(list(a))
for i in range(r):
	if 'S' not in arr[i]:
		k += c
		r2 -= 1
for j in range(c):
	for i in range(r):
		if 'S' == arr[i][j]:
			break
	else:
		k += r2
print(k)


(r, c) = map(int, input().strip().split(' '))
arr = [[j for j in input().strip()] for i in range(r)]
(count1, count2) = (0, 0)
for i in range(r):
	if arr[i] == ['.'] * c:
		count1 += 1
for j in range(c):
	(i, a) = (0, [])
	while i < r:
		if arr[i][j] == '.':
			a.append('.')
		i += 1
	if len(a) == r:
		count2 += 1
print(c * count1 + r * count2 - count1 * count2)


(r, c) = map(int, input().split())
a = [input() for i in range(r)]
count = 0
for x in range(r):
	if 'S' not in a[x]:
		a[x] = 'I' * c
		count += c
for y in range(c):
	var = 0
	for x in range(r):
		if a[x][y] == '.':
			var += 1
		elif a[x][y] == 'S':
			var = 0
			break
	count += var
print(count)


(r, c) = map(int, input().split())
n = [0] * r
m = [0] * c
d = r * c
for i in range(r):
	l = list(map(str, input()))
	for j in range(c):
		if l[j] == 'S':
			n[i] = 1
			m[j] = 1
for i in range(r):
	for j in range(c):
		if n[i] == 1 and m[j] == 1:
			d = d - 1
print(d)


(m, n) = map(int, input().split())
mat = []
count = 0
c = 0
sx = 0
c2 = 0
count2 = 0
for i in range(m):
	mat.append(input())
for i2 in mat:
	count2 += i2.count('.' * n)
for j in range(n):
	for j2 in range(m):
		if mat[j2][j] == '.':
			c = 1
		else:
			c = 0
		sx = sx + c
		if j2 == m - 1:
			c2 = sx
			sx = 0
		if c2 == m:
			count += 1
			c2 = 0
print(count2 * n - count * count2 + count * m)


(rows, cols) = map(int, input().split())
r = [0] * rows
c = [0] * cols
rcount = ccount = 0
for i in range(rows):
	s = input()
	for j in range(cols):
		if s[j] == 'S':
			r[i] = c[j] = 1
for i in range(rows):
	if not r[i]:
		rcount += 1
for i in range(cols):
	if not c[i]:
		ccount += 1
result = cols * rcount + rows * ccount - rcount * ccount
print(result)


a = list(map(int, input().split()))
b = []
for i in range(a[0]):
	b += [input()]
c = 0
d = 0
for i in range(a[0]):
	if b[i].count('S') != 0:
		c += 1
for i in range(a[1]):
	if [j[i] for j in b].count('S') != 0:
		d += 1
print(a[0] * a[1] - c * d)


(r, c) = map(int, input().split())
k = 0
l = []
m = 0
for i in range(r):
	s = input()
	l.append(s)
	if s.count('S') == 0:
		k += 1
for i in range(c):
	test = True
	for j in range(r):
		if l[j][i] == 'S':
			test = False
	if test:
		m += 1
print(c * k + r * m - m * k)


(r, c) = map(int, input().split())
l = []
ar = []
for i in range(r):
	s = input()
	arr = []
	for i in s:
		arr.append(i)
	l.append(arr)
for j in range(c):
	a = []
	for i in range(r):
		a.append(l[i][j])
	ar.append(a)
s = set()
for i in range(r):
	if 'S' not in l[i]:
		for j in range(c):
			s.add((i, j))
for i in range(c):
	if 'S' not in ar[i]:
		for j in range(r):
			s.add((j, i))
print(len(s))


(n, m) = map(int, input().split())
a = []
b = []
(x, y) = (0, 0)
for i in range(n):
	a.append(list(input()))
for i in range(m):
	b.append(['.'] * n)
for i in range(n):
	for j in range(m):
		if not 'S' in a[i][0:m + 1]:
			x += 1
		break
for i in range(m):
	for j in range(n):
		b[i][j] = a[n - 1 - j][i]
for i in range(m):
	for j in range(n):
		if not 'S' in b[i][0:n + 1]:
			y += 1
		break
print(x * m + y * n - x * y)


from sys import stdin, stdout
nm = list(map(int, stdin.readline().split()))
n = nm[0]
m = nm[1]
count = 0
cake = []
for i in range(n):
	row = stdin.readline().strip()
	if 'S' not in row:
		count += m
	else:
		cake.append(row)
for cell in range(m):
	col = ''
	for i in cake:
		col += i[cell]
	if 'S' not in col:
		count += len(col)
stdout.write(str(count))


(r, c) = map(int, input().split())
s = [input() for _ in range(r)]
s = [t if t.count('S') != 0 else 't' * c for t in s]
k = c * sum([t[0] == 't' for t in s])
for j in range(c):
	if all([s[i][j] != 'S' for i in range(r)]):
		k += sum([s[i][j] != 't' for i in range(r)])
print(k)


(n, m) = [int(i) for i in input().split()]
mat = []
for i in range(n):
	s = str(input())
	a = list(s)
	mat.append(a)
line = 0
ans = 0
lines = 0
for i in range(0, len(mat)):
	e = ''
	for j in range(0, len(mat[i])):
		e = e + mat[i][j]
	if e.count('.') == len(e):
		line = line + 1
		ans = ans + len(e)
for i in range(0, m):
	e = ''
	for j in range(0, len(mat)):
		e = e + mat[j][i]
	if e.count('.') == len(e):
		lines = lines + 1
		ans = ans + len(e)
print(ans - line * lines)


(row, column) = map(int, input().split())
cr = 0
cc = 0
table = []
for _ in range(row):
	table.append(input())
cr = table.count('.' * column)
for j in range(column):
	check = True
	for i in range(row):
		if table[i][j] == 'S':
			check = False
			break
	if check:
		cc += 1
print(cr * column + cc * row - cc * cr)


(r, c) = [int(f) for f in input().split()]
x = 0
y = 0
cake = []
for i in range(r):
	b = input()
	cake.append(b)
	if 'S' not in b:
		x += 1
for f in range(c):
	for i in range(r):
		if cake[i][f] == 'S':
			break
	else:
		y += r - x
print(x * c + y)


(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())
table1 = list()
table2 = list()
sum = 0
counter = 0
for i in range(r):
	table1.append(input())
for i in range(c):
	str = ''
	for j in range(r):
		str += table1[j][i]
	table2.append(str)
for i in range(r):
	if 'S' in table1[i]:
		continue
	else:
		sum += c
		counter += 1
for i in range(c):
	if 'S' in table2[i]:
		continue
	else:
		sum += r - counter
print(sum)


(n, m) = [int(i) for i in input().split()]
arr = []
for i in range(n):
	l = [a for a in input()]
	arr.append(l)
row = set()
col = set()
for i in range(n):
	for j in range(m):
		if arr[i][j] == 'S':
			row.add(i)
			col.add(j)
print(n * m - len(row) * len(col))


(r, c) = list(map(int, input().split()))
m = [input() for _ in range(r)]
print(sum((c for r in m if 'S' not in r)) + sum((r - sum((1 for r in m if 'S' not in r)) for c in zip(*m) if 'S' not in c)))


(n, m) = map(int, input().split())
c_n = [1] * m
c_m = 0
for _ in range(n):
	s = input()
	if 'S' in s:
		for i in range(m):
			if s[i] == 'S':
				c_n[i] = 0
	else:
		c_m += 1
print(c_m * m + c_n.count(1) * (n - c_m))


(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) = list(map(int, input().split()))
matrix = []
cakes = 0
for i in range(r):
	dat = input()
	if dat.count('S') != 0:
		matrix.append(dat)
	else:
		cakes += c
for i in range(c):
	flag = 0
	for j in range(len(matrix)):
		if matrix[j][i] == 'S':
			flag = 1
			break
	if flag == 0:
		cakes += len(matrix)
print(cakes)


iarr = list(map(int, input().split()))
r = iarr[0]
c = iarr[1]
arr = []
flag = [0 for i in range(c)]
badrows = 0
for i in range(r):
	s = input()
	arr.append(s)
	if s != '.' * c:
		badrows += 1
	for i in range(c):
		if s[i] == 'S':
			flag[i] = 1
badcols = sum(flag)
ans = r * c - badrows * badcols
print(ans)


(r, c) = [int(i) for i in input().split()]
a = []
ans = 0
h = r
for i in range(r):
	cur = list(input().split()[0])
	if 'S' not in cur:
		ans += c
		h -= 1
	else:
		a.append(cur)
a_t = list(zip(*a))
for elem in a_t:
	if 'S' not in elem:
		ans += h
print(ans)


(r, c) = map(int, input().split())
A = []
ear = 0
evc = []
for i in range(r):
	s = input()
	R = []
	for j in range(c):
		R += [s[j]]
	A += [R]
for i in range(r):
	ev = 0
	for j in range(c):
		if A[i][j] == 'S':
			evc += [j]
			ev = 1
	if ev == 0:
		ear += 1
evc = set(evc)
eac = c - len(evc)
print(ear * c + (r - ear) * eac)


(r, c) = input().split()
line = [0] * int(c)
r_num = 0
for _ in [0] * int(r):
	S_in = 0
	c_num = 0
	for i in input():
		if i == 'S':
			line[c_num] = 1
			S_in = 1
		c_num += 1
	r_num += S_in
print(int(r) * int(c) - r_num * sum(line))


(n, m) = map(int, input().split())
a = []
b = []
f = int(0)
x = 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 = count + m
x = 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:
		count = count + (n - x)
print(count)


import sys
my_file = sys.stdin
line = [int(i) for i in my_file.readline().strip('\n').split()]
(r, c) = (line[0], line[1])
table = my_file.read().split()
new_table = []
for line in table:
	if 'S' in line:
		new_table.append(line)
res = (len(table) - len(new_table)) * c
r -= len(table) - len(new_table)
for col in range(c):
	for row in range(r):
		if 'S' in new_table[row][col]:
			break
	else:
		res += r
print(res)


a = input().split()
r = int(a[0])
c = int(a[1])
s = []
cr = 0
cc = 0
k = 0
for i in range(r):
	s.append(input())
for i in range(r):
	if 'S' not in s[i]:
		cr += 1
for i in range(c):
	for j in range(r):
		if s[j][i] == 'S':
			k = 0
			break
		else:
			k += 1
		if k == r:
			cc += 1
			k = 0
print(cr * c + cc * (r - cr))


import math

def get_primes(prime_supr):
	is_prime = [0] * 2 + [1] * prime_supr
	for i in range(2, int(math.sqrt(prime_supr)) + 1):
		if is_prime[i]:
			for j in range(i * i, prime_supr + 1, i):
				is_prime[j] = 0
	return is_prime
get_int = lambda : map(int, input().split())
(r, c) = get_int()
a = []
ans = 0
for i in range(r):
	a.append(input())
	if 'S' not in a[i]:
		ans += c
		a[i] = 'u' * c
for i in range(c):
	if 'S' not in [a[j][i] for j in range(r)]:
		ans += [a[j][i] for j in range(r)].count('.')
print(ans)


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


(n, m) = map(int, input().split())
a = [input() for i in range(n)]
r = [1 for i in a if 'S' in i]
l = [1 for i in zip(*a) if 'S' in i]
print(n * m - len(r) * len(l))


(r, c) = map(int, input().split())
cake_row = [input() for i in range(r)]
free_row = len([1 for i in cake_row if 'S' not in i])
free_col = len([1 for i in zip(*cake_row) if 'S' not in i])
print(free_col * (r - free_row) + free_row * c)


(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:
		for j in range(c):
			if i[j] == 'S':
				st.append(j)
cl = c - len(set(st))
e1 = (r - r1) * cl
print(e + e1)


(r, c) = map(int, input().split())
grid = []
for _ in range(r):
	grid.append(input())
for i in range(r):
	if 'S' not in grid[i]:
		grid[i] = grid[i].replace('.', '0')
grid1 = []
for j in range(c):
	x = ''
	for i in range(r):
		x = x + grid[i][j]
	grid1.append(x)
for i in range(c):
	if 'S' not in grid1[i]:
		grid1[i] = grid1[i].replace('.', '0')
ans = 0
for i in range(c):
	ans = ans + grid1[i].count('0')
print(ans)


(r, c) = map(int, input().split())
a = 0
b = []
e = [list(input()) for i in range(r)]
for i in e:
	if 'S' in i:
		a += 1
	while 'S' in i:
		b.append(i.index('S'))
		i[i.index('S')] = 0
print(int(r * c - a * len(set(b))))


import sys
try:
	sys.stdin = open(sys.path[0] + '\\input.txt', 'r')
	sys.stdout = open(sys.path[0] + '\\output.txt', 'w')
except Exception as e:
	pass
(r, c) = list(map(int, input().split()))
rows = set()
cols = set()
for i in range(r):
	line = input()
	for j in range(c):
		if line[j] == 'S':
			rows.add(i)
			cols.add(j)
res = 0
for i in range(r):
	for j in range(c):
		if not (i in rows and j in cols):
			res += 1
print(res)


(r, c) = map(int, input().split())
mat = []
for i in range(r):
	mat.append(list(str(input())))
(rr, cc) = (set(), set())
for i in range(r):
	for j in range(c):
		if mat[i][j] == 'S':
			rr.add(i)
			cc.add(j)
print(r * c - len(rr) * len(cc))


(a, b) = list(map(int, input().split()))
l = []
c = 0
y = 0
for i in range(a):
	u = input()
	l += [u]
	if u.count('.') == b:
		y += 1
		c += b
t = ''
h = 0
for i in range(b):
	for j in range(a):
		t += l[j][i]
	if t.count('.') == a:
		h += 1
		c += a
	t = ''
c = c - h * y
print(c)


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	(h, w) = LI()
	field = [S() for _ in range(h)]
	check = [[0] * w for _ in range(h)]
	for i in range(h):
		f = False
		for j in range(w):
			if field[i][j] == 'S':
				f = True
		if not f:
			for j in range(w):
				check[i][j] = 1
	for i in range(w):
		f = False
		for j in range(h):
			if field[j][i] == 'S':
				f = True
		if not f:
			for j in range(h):
				check[j][i] = 1
	ans = 0
	for x in check:
		ans += x.count(1)
	return ans
print(main())


def main():
	[n_rows, n_cols] = [int(_) for _ in input().split()]
	rows = []
	for _ in range(n_rows):
		rows += [[c for c in input()]]
	for i in range(n_rows):
		if 'S' not in rows[i]:
			rows[i] = ['E'] * n_cols
	for i in range(n_cols):
		col = [rows[j][i] for j in range(n_rows)]
		if 'S' not in col:
			for j in range(n_rows):
				rows[j][i] = 'E'
	n_eaten = 0
	for i in range(n_rows):
		n_eaten += sum((rows[i][j] == 'E' for j in range(n_cols)))
	print(n_eaten)
main()


def cellsToConsume(matrix):
	columnsToConsume = 0
	for i in range(len(matrix)):
		strawberryFound = False
		for j in range(len(matrix[0])):
			if matrix[i][j] == 'S':
				strawberryFound = True
				break
		if not strawberryFound:
			columnsToConsume += 1
	rowsToConsume = 0
	for j in range(len(matrix[0])):
		strawberryFound = False
		for i in range(len(matrix)):
			if matrix[i][j] == 'S':
				strawberryFound = True
				break
		if not strawberryFound:
			rowsToConsume += 1
	return len(matrix) * rowsToConsume + (len(matrix[0]) - rowsToConsume) * columnsToConsume
(n, m) = map(int, input().split())
matrix = []
for _ in range(n):
	matrix.append(input())
print(cellsToConsume(matrix))


(n, m) = map(int, input().split())
mat = []
for i in range(n):
	p = input()
	x = [item for item in p]
	mat.append(x)
rowCount = 0
colCount = 0
for i in range(n):
	z = True
	for j in range(m):
		if mat[i][j] == 'S':
			z = False
			break
	if z:
		rowCount += 1
for i in range(m):
	z = True
	for j in range(n):
		if mat[j][i] == 'S':
			z = False
			break
	if z:
		colCount += 1
mi = rowCount * colCount
print(rowCount * m + colCount * n - mi)


(bawah, kanan) = map(int, input().split())
kolom = []
baris = []
for z in range(bawah):
	x = input()
	for zz in range(len(x)):
		if x[zz] == 'S':
			if zz not in kolom:
				kolom.append(zz)
			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) = list(map(int, input().split()))
rd = set()
cd = set()
for i in range(r):
	for (j, ele) in enumerate(input()):
		if ele == 'S':
			rd.add(i)
			cd.add(j)
print(r * c - len(rd) * len(cd))


(r, c) = input().split()
(r, c) = (int(r), int(c))
A = []
B = []
for i in range(0, r):
	a = input()
	for j in range(0, c):
		if a[j] == 'S':
			A.append(i)
			B.append(j)
A = list(set(A))
B = list(set(B))
Sum = r * c - len(A) * len(B)
if Sum > 0:
	print(Sum)
else:
	print(0)


(r, c) = list(map(int, input().rstrip().split()))
l = []
for i in range(r):
	l.append(input())
(nor, noc) = (0, 0)
for i in l:
	if 'S' in i:
		nor += 1
for i in range(c):
	if 'S' in [row[i] for row in l]:
		noc += 1
print(r * c - nor * noc)


(r, c) = map(int, input().split())
a = [input() for i in range(r)]
b = [[0] * c for i in range(r)]
for i in range(r):
	if 'S' not in a[i]:
		for j in range(c):
			b[i][j] = 1
for j in range(c):
	is_find = False
	for i in range(r):
		if a[i][j] == 'S':
			is_find = True
			break
	if not is_find:
		for i in range(r):
			b[i][j] = 1
count = 0
for i in b:
	count += i.count(1)
print(count)


(n, m) = map(int, input().split())
f = [[False for i in range(m)] for j in range(n)]
l = []
for i in range(n):
	k = list(input())
	l.append(k)
e = 0
for i in range(n):
	if 'S' not in l[i]:
		e += m
		f[i] = m * [True]
for i in range(m):
	t = True
	r = 0
	for j in range(n):
		if l[j][i] == 'S':
			t = False
		if f[j][i] == False:
			r += 1
	if t:
		e += r
print(e)


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


import sys
import math as m

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l
mod = int(1000000000.0) + 7

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

def iinp():
	return int(input())

def ninp():
	return map(int, sys.stdin.readline().strip().split())

def linp():
	return list(map(int, sys.stdin.readline().strip().split()))

def p(a):
	print(a)

def p2(a, b):
	print(a, b)
(r, c) = ninp()
bc = []
cnt = 0
br = 0
for i in range(r):
	s = sinp()
	ind = 1
	f = 0
	for char in s:
		if char == 'S':
			bc.append(ind)
			f = 1
		ind += 1
	if f == 0:
		cnt = cnt + c
		br += 1
x = set(bc)
cnt = cnt + (c - len(x)) * (r - br)
p(cnt)


(m, n) = map(int, input().split())
rows = dict(((i, True) for i in range(m)))
cols = dict(((j, True) for j in range(n)))
graph = [input() for _ in range(m)]
for i in range(m):
	for j in range(n):
		if graph[i][j] == 'S':
			rows[i] = False
			cols[j] = False
ans = 0
for i in range(m):
	for j in range(n):
		ans += cols[j] or rows[i]
print(ans)


(r, c) = map(int, input().split())
m = []
for i in range(r):
	m.append(list(input()))
cnt = 0
for i in range(r):
	if not 'S' in m[i]:
		for j in range(c):
			if m[i][j] == '.':
				cnt += 1
				m[i][j] = ''
for j in range(c):
	f = False
	for i in range(r):
		if m[i][j] == 'S':
			f = True
	if f:
		continue
	for i in range(r):
		if m[i][j] == '.':
			cnt += 1
			m[i][j] = ''
print(cnt)


(r, c) = (int(i) for i in input().split(' '))
m = []
for i in range(r):
	m.append([i for i in input()])
t = 0
for i in range(len(m)):
	if 'S' in m[i]:
		continue
	elif '.' in m[i]:
		for j in range(len(m[i])):
			if m[i][j] == '.':
				m[i][j] = 'E'
				t += 1
for j in range(len(m[0])):
	s = False
	f = False
	keep = []
	for i in range(len(m)):
		if m[i][j] == 'S':
			s = True
			continue
		elif m[i][j] == '.':
			f = True
		keep.append((i, j))
	if not s and f:
		for k in keep:
			if m[k[0]][k[1]] == '.':
				t += 1
				m[k[0]][k[1]] = 'E'
print(t)


import sys
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().rstrip().split())
inl = lambda : list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))
(r, c) = inm()
col = [0] * c
count = 0
for _ in range(r):
	s = ins()
	for i in range(c):
		col[i] += 1 if s[i] == '.' else -1
	if 'S' not in s:
		count += c
if r == count // c:
	print(count)
else:
	print(count + col.count(r) * (r - count // c))


(r, c) = map(int, input().split())
row = []
rs = [0 for i in range(r)]
cs = [0 for i in range(c)]
count = 0
for i in range(r):
	s = input()
	row.append(s)
for i in range(r):
	for j in range(c):
		if row[i][j] == 'S':
			rs[i] = 1
			cs[j] = 1
for i in range(r):
	for j in range(c):
		if rs[i] == 0 or cs[j] == 0:
			count += 1
print(count)


(x, z) = input().split()
x = int(x)
z = int(z)
ciasto = []
ciasto_inv = []
for i in range(x):
	ciasto.append(list(input()))
licz = 0
for i in range(x):
	if 'S' in ciasto[i]:
		continue
	for j in range(z):
		if ciasto[i][j] == '.':
			licz += 1
			ciasto[i][j] = '#'
for i in range(z):
	nowy_wiersz = []
	for j in range(x):
		nowy_wiersz.append(ciasto[j][i])
	ciasto_inv.append(nowy_wiersz)
for i in range(z):
	if 'S' in ciasto_inv[i]:
		continue
	for j in range(x):
		if ciasto_inv[i][j] == '.':
			licz += 1
print(licz)


l = input().split()
r = int(l[0])
c = int(l[1])
l = []
nbline = 0
nbcolone = 0
for i in range(r):
	l.append(input())
for s in l:
	if 'S' not in s:
		nbline += 1
for j in range(c):
	exist = False
	for i in range(r):
		if l[i][j] == 'S':
			exist = True
	if exist == False:
		nbcolone += 1
print(nbline * c + nbcolone * r - nbline * nbcolone)


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)


def how_many(rows, cols):
	n = 0
	for i in range(len(rows)):
		if 'S' not in rows[i]:
			for j in range(len(cols)):
				rows[i][j] = 'E'
				cols[j][i] = 'E'
				n += 1
	for j in range(len(cols)):
		if 'S' not in cols[j]:
			n += cols[j].count('.')
	return n

def main():
	first_line = input()
	first_line = first_line.split()
	r = int(first_line[0])
	c = int(first_line[1])
	rows = []
	for i in range(r):
		line = input()
		rows += [list(line)]
	coloumns = [[rows[i][j] for i in range(r)] for j in range(c)]
	print(how_many(rows, coloumns))
main()


(n, m) = list(map(int, input().split()))
t = []
for i in range(n):
	t.append(input())
ans = 0
for i in range(n):
	for j in range(m):
		type = False
		for k in range(n):
			if t[k][j] == 'S':
				type = True
				break
		if not type:
			ans += 1
		else:
			type = False
			for k in range(m):
				if t[i][k] == 'S':
					type = True
					break
			if not type:
				ans += 1
print(ans)


(r, c) = map(int, input().split())
cake = []
for i in range(r):
	cake.append(list(map(str, input())))
sukses = 0
for j in range(r):
	if 'S' not in cake[j]:
		sukses += cake[j].count('.')
		for n in range(c):
			cake[j][n] = 'P'
for k in range(c):
	S = 0
	for l in range(r):
		if cake[l][k] == 'S':
			S += 1
	if S <= 0:
		for m in range(r):
			if cake[m][k] == '.':
				sukses += 1
print(sukses)


(r, c) = [int(i) for i in input().split()]
row = []
ans = 0
for i in range(r):
	s = [ch for ch in input()]
	if 'S' not in s:
		ans += c
		s = 'X' * c
	row.append(s)
for i in range(c):
	col = []
	for j in range(r):
		col.append(row[j][i])
	if 'S' not in col:
		ans += col.count('.')
print(ans)


def f(j, rows):
	c = 0
	for i in range(len(rows)):
		if rows[i][j] == 'S':
			return (0, False)
		elif rows[i][j] == '.':
			c += 1
	return (c, True)
(r, c) = [int(x) for x in input().split()]
rows = []
for i in range(r):
	rows.append(input())
cells = 0
for i in range(r):
	if 'S' not in rows[i]:
		rows[i] = '0' * c
		cells += c
for j in range(c):
	(x, y) = f(j, rows)
	if y == True:
		cells += x
print(cells)


(n, m) = input().split(' ')
n = int(n)
m = int(m)
a = []
d = []
f = []
e = 0
for i in range(n):
	a.append([])
	c = input()
	for j in range(m):
		a[i].append(c[j])
for i in range(n):
	e = 0
	for j in range(m):
		if a[i][j] != 'S':
			e += 1
	if e == m:
		d.append(i)
for i in range(m):
	e = 0
	for j in range(n):
		if a[j][i] != 'S':
			e += 1
	if e == n:
		f.append(i)
print(len(d) * m + len(f) * n - len(d) * len(f))


(r, c) = map(int, input().split())
cake = []
for i in range(r):
	cake.append(list(input()))
nr = set()
nc = set()
for i in range(r):
	if 'S' in cake[i]:
		nr.add(i)
for i in range(c):
	for j in range(r):
		if cake[j][i] == 'S':
			nc.add(i)
			break
for i in range(r):
	if i not in nr:
		for j in range(c):
			cake[i][j] = 'o'
for i in range(c):
	if i not in nc:
		for j in range(r):
			cake[j][i] = 'o'
ret = 0
for i in range(r):
	for j in range(c):
		if cake[i][j] == 'o':
			ret += 1
print(ret)


(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)


(r, c) = map(int, input().split())
l = []
(rs, cs) = (0, 0)
for _ in range(r):
	s = input()
	rs += 'S' in s
	l.append(s)
for i in range(c):
	for j in range(r):
		if l[j][i] == 'S':
			cs += 1
			break
rs = r - rs
cs = c - cs
ans = rs * c + cs * r - rs * cs
print(ans)


import sys
from collections import defaultdict
(r, c) = map(int, sys.stdin.readline().split())
grid = list(map(lambda l: sys.stdin.readline().strip(), range(r)))
frow = defaultdict(lambda : False)
fcol = defaultdict(lambda : False)
for i in range(r):
	for j in range(c):
		if grid[i][j] == 'S':
			frow[i] = True
			fcol[j] = True
ans = 0
for i in range(r):
	for j in range(c):
		if not frow[i] or not fcol[j]:
			ans += 1
sys.stdout.write(str(ans))


def cakeminator(r, c, alist):
	collist = []
	for i in range(0, c):
		isColEditable = True
		isCakeAvailable = False
		for j in range(0, r):
			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
				thisRowEdibleCount += 1
			elif alist[i][j] == 'S':
				isRowEditable = False
		if isCakeAvailable and isRowEditable:
			rowlist.append(i)
			allRowsEdibleCount += thisRowEdibleCount
	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(cakeminator(n, m, blist))


(r, c) = map(int, input().split())
rows = set()
cols = set()
for ri in range(r):
	s = input().strip()
	for ci in range(c):
		if s[ci] == 'S':
			rows.add(ri)
			cols.add(ci)
print(r * c - len(rows) * len(cols))


a = [int(n) for n in input().split(' ')]
n = a[0]
m = a[1]
r = []
c = 0
t = []
for i in range(n):
	k = 0
	s = str(input())
	for j in range(len(s)):
		if s[j] == 'S':
			k = k + 1
			r.append(j)
	if k > 0:
		c = c + 1
for i in range(len(r)):
	if t.count(r[i]) == 0:
		t.append(r[i])
p = len(t)
print(n * m - c * p)


s = input().split()
r = int(s[0])
c = int(s[1])
a = []
e = 0
f = 0
for i in range(r):
	d = input()
	list(d)
	a.append(d)
for i in a:
	if i.find('S') == -1:
		e += 1
for i in range(c):
	z = 0
	for d in range(r):
		if a[d][i] == 'S':
			z = 1
	if z == 0:
		f += 1
print(e * c + f * (r - e))


x = list(map(int, input().split()))
r = x[0]
c = x[1]
l = []
mat = [[0] * c for i in range(r)]
rows = set()
cols = set()
for i in range(r):
	l.append(str(input()))
for i in range(r):
	for j in range(c):
		if l[i][j] == '.':
			mat[i][j] = 1
		elif l[i][j] == 'S':
			mat[i][j] = 2
			rows.add(i)
			cols.add(j)
cnt = 0
for i in range(r):
	if i not in rows:
		for j in range(c):
			mat[i][j] = 0
			cnt += 1
for j in range(c):
	if j not in cols:
		for i in range(r):
			if mat[i][j] == 1:
				mat[i][j] = 0
				cnt += 1
print(cnt)


(r, c) = map(int, input().split(sep=' '))
(a, l) = (list(), list())
n = 0
for i in range(r):
	a.append(input()[0:c])
for i in range(r):
	for j in range(c):
		if a[i][j] == 'S':
			n += 1
			l.append([i, j])
k = list()
for i in l:
	for j in l:
		if i != j and [j[0], i[1]] not in l:
			if [j[0], i[1]] not in k:
				k.append([j[0], i[1]])
n += k.__len__()
print(r * c - n)


l = input().split()
(row, col) = (int(l[0]), int(l[1]))
count = 0
rowDic = {}
colDic = {}
strawCount = 0
while count < row:
	l = input()
	for i in range(len(l)):
		if l[i] == 'S':
			rowDic[count] = 1
			colDic[i] = 1
			strawCount += 1
	count += 1
cantEat = 0
if strawCount:
	for i in range(row):
		for j in range(col):
			if rowDic.get(i, 0) > 0 and colDic.get(j, 0) > 0:
				cantEat += 1
print(row * col - cantEat)


(r, c) = map(int, input().split())
r0 = []
c0 = []
for i in range(r):
	s = input()
	for j in range(c):
		if s[j] == 'S':
			r0.append(i)
			c0.append(j)
r0 = set(r0)
c0 = set(c0)
print(r * c - len(r0) * len(c0))


(r, c) = map(int, input().split())
a = []
[a.append(input()) for _ in range(r)]
k = 0
t = 0
for i in range(r - 1, -1, -1):
	if 'S' in a[i]:
		continue
	else:
		k += len(a[i])
		a.remove(a[i])
		r -= 1
for j in range(c):
	for i in range(r):
		if a[i][j] == 'S':
			continue
		else:
			t += 1
	if t == r:
		k += t
	t = 0
print(k)


(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())
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)


grid = [int(i) for i in input().split(' ')]
r = grid[0]
c = grid[1]
e_c = set()
e_r = set()
for i in range(r):
	t = list(input())
	for j in range(len(t)):
		if t[j] == 'S':
			e_c = e_c | set([j])
			e_r = e_r | set([i])
print(r * c - len(e_r) * len(e_c))


(r, c) = map(int, input().strip().split())
g = []
for i in range(0, r):
	g.append(list(input().strip()))
res = 0
for i in g:
	if 'S' not in i:
		for j in range(0, c):
			if i[j] == '.':
				res += 1
				i[j] = -1
g_t = [[] for a in range(0, c)]
for i in range(0, c):
	for j in range(0, r):
		g_t[i].append(g[j][i])
for i in g_t:
	if 'S' not in i:
		for j in range(0, r):
			if i[j] == '.':
				res += 1
				i[j] = -1
print(res)


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)
main()


def eat_cake(cols, rows, string):
	result = 0
	for i in range(0, rows):
		if 'S' not in string[i]:
			result += cols
			string[i] = string[i].replace('.', 'E')
	for i in range(0, cols):
		contains = False
		all_eaten = True
		already_eaten = 0
		for j in range(0, rows):
			if string[j][i] == 'S':
				contains = True
			if string[j][i] == '.':
				all_eaten = False
			if string[j][i] == 'E':
				already_eaten += 1
		if all_eaten == False and contains == False:
			result += rows - already_eaten
			for row in range(0, rows):
				string[row] = string[row][0:i] + 'E' + string[row][i + 1:]
	return result

def main():
	first_line = input()
	first_line = first_line.split()
	rows = int(first_line[0])
	coloumns = int(first_line[1])
	l = []
	for i in range(rows):
		line = input()
		l.append(line)
	print(eat_cake(coloumns, rows, l))
main()


(r, c) = map(int, input().split())
v = [1] * c
d = 0
for _ in range(r):
	s = list(input())
	for i in range(len(s)):
		if s[i] == 'S':
			v[i] = 0
	if 'S' not in s:
		d += 1
f = sum(v)
print(d * c + r * f - d * f)


(n, m) = map(int, input().split())
a = []
count = 0
r = 0
col = 0
s = 0
z = 0
x = 0
y = 0
for i in range(n):
	a.append(list(input()))
while n * m >= z:
	z += 1
	if x == n:
		break
	if a[x][y] == '.' and y < m:
		y += 1
		if y == m:
			x += 1
			y = 0
			r += 1
			count += m
	elif a[x][y] == 'S' and x < n:
		x += 1
		y = 0
x = 0
y = 0
while n * m >= s:
	s += 1
	if y == m:
		break
	if a[x][y] == '.' and x < n:
		x += 1
		if x == n:
			y += 1
			x = 0
			col += 1
			count += n
	elif a[x][y] == 'S' and y < m:
		y += 1
		x = 0
count = count - r * col
print(count)


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


(n, m) = map(int, input().split())
lst = [list(input()) for _ in range(n)]
count = 0
for j in range(m):
	col = [lst[k][j] for k in range(n)]
	if 'S' not in col:
		for i in range(n):
			if lst[i][j] == '.':
				count += 1
				lst[i][j] = '*'
for i in range(n):
	if 'S' in lst[i]:
		continue
	else:
		for j in range(m):
			if lst[i][j] == '.':
				count += 1
				lst[i][j] = '*'
print(count)


(r, c) = input().split()
(r, c) = (int(r), int(c))
sol = 0
cols = set()
colsub = 0
for i in range(r):
	s = input()
	straw = False
	for j in range(c):
		if s[j] == 'S':
			straw = True
			cols.add(j)
	if not straw:
		sol += c
		colsub += 1
sol += (c - len(cols)) * r - (c - len(cols)) * colsub
print(sol)


count = 0
srr = ''
(p, l) = map(int, input().split())
grid = []
for i in range(p):
	grid.append(input())
for i in range(p):
	if 'S' not in grid[i]:
		for j in grid[i]:
			srr = srr + '1'
		grid[i] = srr
		count = count + l
for i in range(l):
	flag = 0
	for j in range(p):
		if 'S' == grid[j][i]:
			flag = 1
			break
	if flag == 0:
		for k in range(p):
			if grid[k][i] == '.':
				count = count + 1
print(count)


(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, input().split())
s = set()
e = set()
for i in range(r):
	tmp = input()
	for j in range(c):
		if tmp[j] == 'S':
			s.add((i, j))
for s1 in s:
	for s2 in s:
		if s1 != s2 and (s1[0] != s2[0] or s1[1] != s2[1]):
			e.add((s1[0], s2[1]))
			e.add((s2[0], s1[1]))
print(r * c - len(s.union(e)))


(n, k) = map(int, input().split())
a = []
c = []
x = 0
d = 0
for i in range(n):
	a.append(input())
for i in range(n - 1, -1, -1):
	if not 'S' in a[i]:
		x += len(a[i])
		del a[i]
		d += 1
for i in range(k):
	b = []
	for j in range(n - d):
		b.append(a[j][i])
	c.append(b)
	c[i] = ''.join(c[i])
for i in range(k - 1, -1, -1):
	if not 'S' in c[i]:
		x += len(c[i])
		del c[i]
		d += 1
print(x)


import sys
fin = sys.stdin
(n, m) = map(int, fin.readline().split())
isRowFree = [True] * n
isColFree = [True] * m
for i in range(n):
	s = fin.readline().strip()
	for j in range(m):
		if s[j] == 'S':
			isRowFree[i] = False
			isColFree[j] = False

def FreeRows():
	return sum((1 for i in range(n) if isRowFree[i]))

def FreeColumns():
	return sum((1 for i in range(m) if isColFree[i]))
a = FreeRows()
b = FreeColumns()
print(a * m + b * (n - a))


(a, b) = [int(i) for i in input().split()]
c = [input() for j in range(a)]
d1 = 0
d2 = 0
d = False
for i in range(a):
	if 'S' not in c[i]:
		d1 += b
for i in range(b):
	d = False
	for j in range(a):
		if c[j][i] == 'S':
			d = True
			break
	if not d:
		d2 += a
print(int(d1 + d2 - d2 / a * (d1 / b)))


(r, c) = map(int, input().split())
m = []
ans = 0
for k in range(r):
	a = input()
	if 'S' not in a:
		ans = ans + c
	else:
		ap = list(a)
		m.append(ap)
for j in range(c):
	co = []
	for k in range(len(m)):
		co.append(m[k][j])
	if 'S' not in co:
		ans = ans + len(m)
print(ans)


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()


(r, k) = [int(i) for i in input().split()]
a = []
c = []
(ro, ko) = (0, 0)
for i in range(r):
	b = []
	s = input()
	for f in s:
		if f == 'S':
			ro += 1
			break
	for j in range(k):
		b.append(s[j])
	a.append(b)
for j in range(k):
	for i in range(r):
		if a[i][j] == 'S':
			ko += 1
			break
print((r - ro) * k + (k - ko) * ro)


grid = input()
r = int(grid.split()[0])
rl = []
cl = []
while r > 0:
	c = input()
	for (index, i) in enumerate(c):
		if i == 'S':
			cl.append(index)
			rl.append(r)
	r -= 1
print(int(grid.split()[0]) * int(grid.split()[1]) - len(set(rl)) * len(set(cl)))


(n, k) = map(int, input().split())
ar = []
row = 0
col = 0
count = 0
for i in range(n):
	ar.append(input())
	if 'S' not in ar[i]:
		row += 1
for i in range(k):
	count = 0
	for j in range(n):
		if ar[j][i] == 'S':
			count = 1
			break
	if count == 0:
		col += 1
print(col * n + row * k - row * col)


(r, c) = [int(s) for s in input().split()]
cake = []
row = 0
column = 0
for i in range(r):
	line = input()
	cake.append(line)
	if 'S' not in line:
		row += 1
for i in range(c):
	s = 0
	for j in range(r):
		if cake[j][i] == 'S':
			s += 1
	if s == 0:
		column += 1
print(row * c + column * r - row * column)


(r, c) = map(int, input().split())
arr = [input() for i in range(r)]
a = 0
b = []
g = []
d = []
for i in range(r):
	for j in range(c):
		if arr[i][j] == 'S':
			a += 1
			b.append([i, j])
for k in range(a):
	g.append(b[k][0])
e = set(g)
g = list(e)
for k in range(a):
	d.append(b[k][1])
f = set(d)
d = list(f)
z = (r - len(g)) * c + (c - len(d)) * (r - (r - len(g)))
print(z)


def single_integer():
	return int(input())

def multi_integer():
	return map(int, input().split())

def string():
	return input()

def multi_string():
	return input().split()
(r, c) = multi_integer()
columns = set()
good_row = 0
ans = 0
for i in range(r):
	k = 0
	count = 0
	row = string()
	for j in row:
		if j == 'S':
			count += 1
			columns.add(k)
		k += 1
	if count == 0:
		good_row += 1
		ans += c
print(ans + (c - len(columns)) * (r - good_row))


[n, m] = list(map(int, input().split(' ')))
cr = [1] * n
cc = [1] * m
for i in range(n):
	s = input()
	for j in range(m):
		cr[i] = 0 if s[j] == 'S' else cr[i]
		cc[j] = 0 if s[j] == 'S' else cc[j]
sr = sum(cr)
sc = sum(cc)
result = sr * m + sc * n - sr * sc
print(result)


(r, c) = map(int, input().split())
cake = []
for _ in range(r):
	tmp = list(input())
	tmp = [0 if i == '.' else 1 for i in tmp]
	cake.append(tmp)
p = 0
tr = 0
for i in range(r):
	if sum(cake[i]) == 0:
		p += c
		tr += 1
for i in range(c):
	tmp = 0
	for j in range(r):
		tmp += cake[j][i]
	if tmp == 0:
		p += r - tr
print(p)


(r, c) = map(int, input().split())
L = [str(input()) for _ in range(r)]
C = [0 for _ in range(c)]
R = [0 for _ in range(r)]
for i in range(r):
	for j in range(c):
		if L[i][j] == 'S':
			R[i] = 1
			C[j] = 1
print(r * c - sum(C) * sum(R))


(n, m) = map(int, input().split())
b = []
b1 = []
c = 0
for i in range(n):
	a = str(input())
	b.append(a)
for i in range(len(b)):
	if 'S' not in b[i]:
		c += len(b[i])
		b1.append(i)
b1.reverse()
for i in b1:
	del b[i]
for j in range(m):
	for i in range(len(b)):
		if b[i][j] == 'S':
			break
	else:
		c += len(b)
print(c)


(R, C) = map(int, input().split())
matrix = []
row = set()
col = set()
for i in range(R):
	temp = input().strip()
	for j in range(C):
		if temp[j] == 'S':
			row.add(i)
			col.add(j)
print(R * C - len(row) * len(col))


(N, M) = map(int, input().split())
L = []
count = 0
for i in range(N):
	L.append(list(input()))
for i in range(N):
	for j in range(M):
		(FLAG1, FLAG2) = (0, 0)
		if L[i][j] == '.':
			for k in range(M):
				if L[i][k] == 'S':
					FLAG1 = 1
					break
			for l in range(N):
				if L[l][j] == 'S':
					FLAG2 = 1
					break
			if FLAG1 == 0 or FLAG2 == 0:
				count += 1
print(count)


(r, c) = map(int, input().split())
(row, col) = ([False] * r, [False] * c)
grid = []
for i in range(r):
	grid.append(input())
	for j in range(c):
		if grid[i][j] == 'S':
			row[i] = col[j] = True
cont = 0
for i in range(r):
	for j in range(c):
		cont += not (row[i] and col[j])
print(cont)


(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 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:
	ans = count * c
	i = 0
	for j in range(c):
		for i in range(r):
			if a[i][j] == 'S':
				count1 += 1
				break
	col = c - count1
	ans += col * r
	ans -= count * col
	print(ans)


def cakeminator(cake, r, c):
	total = 0
	for i in range(r):
		if 'S' not in cake[i]:
			for j in range(c):
				if cake[i][j] == '.':
					cake[i][j] = 'x'
					total += 1
	for i in range(c):
		res = []
		for j in range(r):
			res.append(cake[j][i])
		if 'S' not in res:
			total += res.count('.')
	return total

def mkcake(r, c):
	cake = []
	for i in range(r):
		s = list(input())
		cake.append(s)
	return cake

def main():
	(r, c) = map(int, input().split())
	cake = mkcake(r, c)
	print(cakeminator(cake, r, c))
main()


(rows, columns) = map(int, input().split())
occupied_rows = 0
occupied_columns_set = set()
for i in range(rows):
	line = input()
	if 'S' not in line:
		continue
	occupied_rows += 1
	[occupied_columns_set.add(j) for j in range(columns) if line[j] == 'S']
occupied_columns = len(occupied_columns_set)
print(columns * rows - occupied_columns * occupied_rows)


def cmget(s):
	i = 0
	lis = []
	for ch in s:
		if ch == 'S':
			lis.append(i)
		i += 1
	return lis
(r, c) = map(int, input().split())
grid = []
rm = set()
cm = set()
for i in range(r):
	s = input()
	if 'S' in s:
		rm.add(i)
		lis = cmget(s)
		for i in lis:
			cm.add(i)
	grid.append(s)
res = 0
for i in range(r):
	for j in range(len(grid[i])):
		if i in rm and j in cm:
			res += 1
print(r * c - res)


(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())
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)


(r, c) = map(int, input().split())
cake = [input().strip() for _ in range(r)]
ans = 0
for i in range(r):
	for j in range(c):
		if cake[i][j] == '.' and ('S' not in cake[i] or 'S' not in list(zip(*cake))[j]):
			ans += 1
print(ans)


(r, c) = [int(x) for x in input().split(' ')]
grid = []
for _ in range(r):
	grid.append([x for x in input()])
for x in range(r):
	if 'S' not in grid[x]:
		grid[x] = ['1' for i in range(c)]
for x in range(c):
	temp = []
	for row in range(r):
		temp.append(grid[row][x])
	if 'S' not in temp:
		for row in range(r):
			grid[row][x] = '1'
ans = 0
for x in range(r):
	ans += grid[x].count('1')
print(ans)


(n, m) = map(int, input().split())
arr = [str(input()) for i in range(n)]
cnt_row = [0 for i in range(n)]
cnt_col = [0 for i in range(m)]
for i in range(n):
	for j in range(m):
		if arr[i][j] == 'S':
			cnt_row[i] = 1
			cnt_col[j] = 1
print(n * m - sum(cnt_col) * sum(cnt_row))


(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)


(r, c) = map(int, input().split())
s = []
for i in range(r):
	s.append(list(input()))
for i in range(r):
	if s[i].count('S') == 0:
		for j in range(c):
			s[i][j] = '0'
for j in range(c):
	flag = 0
	for i in range(r):
		if s[i][j] == 'S':
			flag = +1
	if flag == 0:
		for i in range(r):
			s[i][j] = '0'
ans = 0
for i in range(r):
	ans += s[i].count('0')
print(ans)


(row, col) = map(int, input().split())
table = [list(map(str, input())) for i in range(row)]
for r in range(row):
	flag = True
	for c in range(col):
		if table[r][c] == 'S':
			flag = False
			break
	if flag:
		for c in range(col):
			table[r][c] = 'e'
for c in range(col):
	flag = True
	for r in range(row):
		if table[r][c] == 'S':
			flag = False
			break
	if flag:
		for r in range(row):
			table[r][c] = 'e'
cont = 0
for r in range(row):
	for c in range(col):
		if table[r][c] == 'e':
			cont += 1
print(cont)


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


(r, c) = [int(x) for x in input().split()]
fnd = 0
cols_idx = []
T = []
for i in range(r):
	ins = list(input())
	if 'S' not in ins:
		fnd += len(ins)
	else:
		T.append(ins)
		cols_idx.extend([i for (i, val) in enumerate(ins) if val == 'S'])
for i in range(c):
	if i in cols_idx:
		continue
	else:
		for j in T:
			j[i] = None
			fnd += 1
print(fnd)


(r, c) = map(int, input().split())
l = []
for i in range(r):
	w = list(input())
	l.append(w)
m = []
h = 0
for i in range(r):
	for j in range(c):
		if l[i][j] != 'S':
			t = [i, j]
			m.append(t)
		else:
			h += 1
if h == 0:
	print(r * c)
else:
	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)
	b = y * u
	o = y * c + u * r - b
	print(o)


(n, m) = list(map(int, input().split()))
l = []
k = 0
for _ in range(n):
	s = input()
	if 'S' not in s:
		k += 1
	l.append(s)
if k == n:
	print(n * m)
else:
	k1 = 0
	for i in range(m):
		s = ''
		for j in range(n):
			s += l[j][i]
		if 'S' not in s:
			k1 += 1
	print(k * m + k1 * n) if k == 0 or k1 == 0 else print(k * m + k1 * n - k * k1)


from itertools import product
(r, c) = map(int, input().split())
cake = []
strawberries_x = set()
strawberries_y = set()
for i in range(r):
	cake.append(input())
	for j in range(c):
		if cake[i][j] == 'S':
			strawberries_x.add(i)
			strawberries_y.add(j)
dangerous_spots = len(set(product(strawberries_x, strawberries_y)))
print(r * c - dangerous_spots)


from collections import deque
from math import log, sqrt, ceil

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def li():
	return list(mi())
(r, c) = mi()
a = []
b = []
for i in range(r):
	s = si()
	for j in range(c):
		if s[j] == 'S':
			a.append(i)
			b.append(j)
c1 = 0
for i in range(r):
	for j in range(c):
		(f, f1) = (0, 0)
		if i not in a:
			f = 1
		if j not in b:
			f1 = 1
		if f == 1 or f1 == 1:
			c1 += 1
print(c1)


(row, col) = map(int, input().split())
grid = []
for i in range(row):
	s = input()
	grid.append(list(s))
for i in range(row):
	for j in range(col):
		if grid[i][j] == 'S':
			break
	else:
		grid[i] = ['X'] * col
for j in range(col):
	for i in range(row):
		if grid[i][j] == 'S':
			break
	else:
		for i in range(row):
			grid[i][j] = 'X'
ans = 0
for line in grid:
	ans += line.count('X')
print(ans)


cake = [int(y) for y in input().split()]
l = []
eaten = 0
columnCakes = int(cake[0])
for var in range(cake[0]):
	l.append(input())
for var in range(cake[0]):
	if l[var] == str('.' * cake[1]):
		eaten += cake[1]
		columnCakes -= 1
for var in range(cake[1]):
	S = False
	for e in l:
		if e[var] == 'S':
			S = True
			break
	if not S:
		eaten += columnCakes
print(eaten)


_ = list(map(int, input().split()))
____ = list()
____.append([0 for i in range(_[0])])
____.append([0 for i in range(_[1])])
for __ in range(_[0]):
	_______ = 0
	___ = input()
	_________ = 0
	for ________ in range(___.count('S')):
		_________ = ___[_______:].find('S')
		if ___ != -1:
			____[1][_________ + _______] = 1
			____[0][__] = 1
		else:
			break
		_______ += _________ + 1
print(____[1].count(0) * _[0] + ____[0].count(0) * _[1] - ____[0].count(0) * ____[1].count(0))


(r, c) = list(map(int, input().split()))
matrix = []
for i in range(r):
	line = list(input())
	matrix.append(line)
matrix90 = []
for i in range(c):
	line = []
	for j in range(r):
		line.append(matrix[j][i])
	matrix90.append(line)
Count = Count2 = 0
for i in matrix:
	if 'S' not in i:
		Count += 1
for i in matrix90:
	if 'S' not in i:
		Count2 += 1
C = Count * len(matrix[0]) + Count2 * len(matrix90[0]) - Count * Count2
print(C)


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
		k[i] = '*' * c
t = list(zip(*k))
for i in range(q):
	a = t[i].count('.')
	if a == r:
		n += r
print(n)


a = input().split()
r = int(a[0])
c = int(a[1])
l = []
for i in range(r):
	s = input()
	l.append(s)
s = 0
for i in range(r):
	if 'S' not in l[i]:
		s = s + c
p = s // c
z = 0
for i in range(c):
	t = 0
	for j in range(r):
		if l[j][i] == 'S':
			t = 1
			break
		else:
			t = 0
	if t == 0:
		z = z + r - p
print(z + s)


(r, c) = map(int, input().split())
a = []
for i in range(r):
	a.append(input())
mas = [[False] * c for i in range(r)]
for i in range(r):
	if 'S' not in a[i]:
		for j in range(c):
			mas[i][j] = True
for j in range(c):
	find = False
	for i in range(r):
		if a[i][j] == 'S':
			find = True
			break
	if not find:
		for i in range(r):
			mas[i][j] = True
k = 0
for i in mas:
	k += i.count(True)
print(k)


(r, c) = map(int, input().split())
lis = []
for i in range(r):
	lis.append(input())
dicr = {}
dicc = {}
for i in range(r):
	for j in range(c):
		if lis[i][j] == 'S':
			dicr[i] = 1
			dicc[j] = 1
count = 0
for i in range(r):
	for j in range(c):
		if lis[i][j] != 'S':
			if dicr.get(i, 0) == 0 or dicc.get(j, 0) == 0:
				count += 1
print(count)


def main():
	(r, c) = map(int, input().split())
	grid = [input() for _ in range(r)]
	rows = [False] * r
	cols = [False] * c
	for x in range(r):
		for y in range(c):
			if grid[x][y] == 'S':
				rows[x] = True
				cols[y] = True
	ans = r * c
	for x in range(r):
		for y in range(c):
			if rows[x] and cols[y]:
				ans -= 1
	print(ans)
main()


(n, m) = map(int, input().split())
l1 = []
l2 = []
for i in range(0, n):
	l3 = [0] * m
	l2.append(l3)
	s = input()
	l1.append(s)
for i in range(0, n):
	if 'S' in l1[i]:
		continue
	else:
		for j in range(0, m):
			l2[i][j] += 1
for i in range(0, m):
	flag = 0
	for j in range(0, n):
		if l1[j][i] == 'S':
			flag = 1
	if flag == 0:
		for j in range(0, n):
			l2[j][i] += 1
x = 0
for item in l2:
	x += item.count(0)
print(n * m - x)


(r, c) = (int(x) for x in input().split())
s = []
n_r = 0
ans = 0
for i in range(r):
	s.append(input())
	if s[i] == '.' * c:
		n_r += 1
		ans += c
for t in map(lambda x: ''.join(x), zip(*s)):
	if t == '.' * r:
		ans += r - n_r
print(ans)


(rows, columns) = map(int, input().strip().split())
matrix = [[0 for x in range(columns)] for y in range(rows)]
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'
for i in range(columns):
	c = 0
	for j in range(rows):
		if matrix[j][i] != 'S':
			c += 1
	if c == rows:
		for j in range(rows):
			if matrix[j][i] != 'v':
				k += 1
print(k)


(r, c) = [int(x) for x in input().split()]
a = [[str(x) for x in input()] for i in range(0, r)]
max_cake = 0
flag = 0
temp = 0
for i in range(0, r):
	count = 0
	for j in range(0, c):
		if a[i][j] == '.':
			count += 1
		if count == c:
			max_cake += count
			temp += 1
for j in range(0, c):
	count = 0
	for i in range(0, r):
		if a[i][j] == '.':
			count += 1
		if count == r:
			max_cake += count
			flag += 1
final = max_cake - flag * temp
print(final)


t = input().split()
S = []
count1 = 0
count2 = 0
L = []
for i in range(int(t[0])):
	S.append(input())
for k in range(int(t[1])):
	l = ''
	for j in range(int(t[0])):
		l += S[j][k]
	L.append(l)
for i in range(int(t[0])):
	if 'S' not in S[i]:
		count1 += 1
for k in range(int(t[1])):
	if 'S' not in L[k]:
		count2 += 1
a = count1 * int(t[1]) + count2 * int(t[0]) - count1 * count2
print(a)


def col(l, c):
	b = True
	for i in range(len(l)):
		if l[i][c] == 'S':
			b = False
			break
	return b
while True:
	try:
		l = []
		(a, b) = map(int, input().split(' '))
		for i in range(a):
			l += [list(input())]
		s = 0
		(r, c) = (0, 0)
		for i in range(len(l)):
			if 'S' in l[i]:
				r += 1
		for j in range(len(l[0])):
			if not col(l, j):
				c += 1
				continue
		print(a * b - r * c)
	except:
		break


s = input().split()
(r, c) = (int(s[0]), int(s[1]))
arr = []
for i in range(r):
	s = input()
	temp = []
	for cc in s:
		temp.append(1 if cc == 'S' else 0)
	arr.append(temp)
for i in range(r):
	if not 1 in arr[i]:
		for j in range(c):
			if arr[i][j] == 0:
				arr[i][j] = 2
a = []
for i in range(c):
	a.append([arr[0][i]])
for i in range(1, r):
	for j in range(c):
		a[j].append(arr[i][j])
for i in range(c):
	if not 1 in a[i]:
		for j in range(r):
			if a[i][j] == 0:
				a[i][j] = 2
ans = 0
for i in range(c):
	for j in range(r):
		ans += 1 if a[i][j] == 2 else 0
print(ans)


(r, c) = map(int, input().split())
r_val = [0] + [c] * r
c_val = [0] + [r] * c
for x in range(1, r + 1):
	line = input()
	for (i, c) in enumerate(line):
		if c == 'S':
			r_val[x] = 0
			c_val[i + 1] = 0
total = 0
for x in r_val:
	total += x
	r -= min(x, 1)
for y in c_val:
	if y > 0:
		total += r
print(total)


def cake_eater():
	size = input().split()
	size = [int(i) for i in size]
	matrix = []
	for i in range(size[0]):
		matrix.append(input())
	output = 0
	rows = {}
	columns = {}
	for i in range(len(matrix)):
		for j in range(len(matrix[i])):
			if matrix[i][j] == 'S':
				rows[i] = 1
				columns[j] = 1
	for i in range(len(matrix)):
		for j in range(len(matrix[i])):
			if matrix[i][j] == '.':
				if i not in rows or j not in columns:
					output += 1
					continue
	print(output)
	return
cake_eater()


(r, c) = map(int, input().rstrip().split())
m = [input() for _ in range(r)]
cm = [[m[i][j] for i in range(r)] for j in range(c)]
rc = count = 0
for i in range(r):
	if 'S' not in m[i]:
		count += c
		rc += 1
for j in range(c):
	if 'S' not in cm[j]:
		count += r - rc
print(count)


(n, m) = map(int, input().split(' '))
L = [input() for x in range(n)]
x = set([])
y = set([])
for i in range(n):
	for j in range(m):
		if L[i][j] == 'S':
			x.add(i)
			y.add(j)
ans = n * (m - len(y)) + m * (n - len(x)) - (m - len(y)) * (n - len(x))
print(ans)


(r, c) = map(int, input().split())
l = [[0] * c] * r
for i in range(r):
	l[i] = list(input())
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)


(a, b) = map(int, input().split(' '))
cake = []
for i in range(a):
	cake.append(input())
eat = 0
for i in range(a):
	if 'S' not in cake[i] and '.' in cake[i]:
		eat += cake[i].count('.')
		cake[i] = cake[i].replace('.', 'x')
for i in range(b):
	if 'S' not in [row[i] for row in cake] and '.' in [row[i] for row in cake]:
		eat += [row[i] for row in cake].count('.')
print(eat)


(r, c) = map(int, input().split(' '))
l = []
c1 = []
t = 0
for i in range(r):
	l1 = input()
	l1 = list(l1)
	if 'S' in l1:
		for j in range(len(l1)):
			if l1[j] == 'S':
				if j in c1:
					continue
				else:
					c1.append(j)
	else:
		t += 1
m = c - len(c1)
n = t
s = m * r + len(c1) * t
print(s)


x = input().split(' ')
(l, w) = (int(x[0]), int(x[1]))
lst = []
for i in range(l):
	x = input()
	lst.append([])
	for j in x:
		lst[i].append(j)
loc = []
print()
for i in range(l):
	loc.append([])
	for j in range(w):
		loc[i].append([i, j])
c = 0
v = 0
eaten_w = []
for i in loc:
	for j in i:
		if lst[j[0]][j[1]] != 'S':
			c += 1
			if c == w:
				for j in i:
					eaten_w.append(j)
	c = 0
r = 0
p = 0
eaten_l = []
for i in range(w):
	for j in range(l):
		d = loc[j][i]
		if lst[d[0]][d[1]] != 'S':
			r += 1
			if r == l:
				for j in range(l):
					d = loc[j][i]
					eaten_l.append(d)
	r = 0
last_lst = eaten_w
for i in eaten_l:
	if i not in last_lst:
		last_lst.append(i)
print(len(last_lst))


(n, m) = map(int, input().split())
count = 0
r = [False] * n
c = [False] * m
for i in range(n):
	s = input()
	for j in range(m):
		if s[j] == 'S':
			r[i] = True
			c[j] = True
print(r.count(False) * m + c.count(False) * n - r.count(False) * c.count(False))


(a, b) = map(int, input().split())
l = []
count = row = 0
for i in range(a):
	l.append(input())
	if 'S' not in l[i]:
		count += 1
for i in range(b):
	col = 0
	for j in range(a):
		if l[j][i] == 'S':
			col += 1
	if col == 0:
		row += 1
print(row * a + count * b - count * row)


(r, c) = [int(i) for i in input().split()]
mass = []
res1 = 0
res2 = 0
for i in range(r):
	s = input()
	mass.append(s)
	if s.find('S') == -1:
		res1 += 1
for j in range(c):
	for i in range(r):
		if mass[i][j] == 'S':
			break
	else:
		res2 += r - res1
print(res1 * c + res2)


(n, d) = input().split()
n = int(n)
d = int(d)
h = [''] * n
s = 0
t = d
for i in range(n):
	h[i] = input()
	if 'S' not in h[i]:
		s += 1
b = [0] * d
for i in range(n):
	for j in range(d):
		if h[i][j] == 'S':
			b[j] = 1
for i in range(d):
	if b[i] == 1:
		t -= 1
print(s * d + t * n - s * t)


(r, c) = map(int, input().split())
a = []
for i in range(r):
	a.append(input())
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
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_str + (total_s_column - total_s_str // c * (total_s_column // r)))


(r, c) = map(int, input().split())
a = [list(input()) for i in range(r)]
r1 = r - sum(('S' in line for line in a))
l2 = list(map(list, zip(*a)))
c1 = c - sum(('S' in line for line in l2))
print(c1 * r + r1 * c - r1 * c1)


(r, c) = map(int, input().split())
row = set()
col = set()
arr = []
for j in range(r):
	temp = list(input())
	z = []
	for (i, item) in enumerate(temp):
		if item == 'S':
			row.add(j)
			col.add(i)
			z.append(-1)
		else:
			z.append(0)
	arr.append(z)
ans = 0
for i in range(r):
	if i not in row:
		for j in range(c):
			if arr[i][j] == 0:
				arr[i][j] = 1
				ans += 1
for j in range(c):
	if j not in col:
		for i in range(r):
			if arr[i][j] == 0:
				arr[i][j] = 1
				ans += 1
print(ans)


area = [int(i) for i in input().split(' ')]
(rows, coleat, cells) = ([], 0, 0)
for row in range(area[0]):
	rows.append(input())
for col in range(area[1]):
	temp = 0
	for row1 in range(area[0]):
		if rows[row1][col] == 'S':
			break
		else:
			temp += 1
	if temp == area[0]:
		cells += temp
		coleat += 1
for row2 in range(area[0]):
	if 'S' not in rows[row2]:
		cells += area[1] - coleat
print(cells)


(r, c) = list(map(int, input().split()))
o = []
piso = []
mal = 0
bien = 0
for i in range(r):
	o.append(list(input()))
j = 0
k = 0
for i in range(r):
	for j in range(c):
		if o[i][j] == 'S':
			mal += 1
			break
for i in range(c):
	for j in range(r):
		if o[j][i] == 'S':
			bien += 1
			break
print(r * c - mal * bien)


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()


(n, m) = map(int, input().split())
s_row = []
s_col = []
cake = []
for i in range(n):
	x = [i for i in input()]
	cake.append(x)
	for j in range(len(x)):
		if x[j] == 'S':
			s_row.append(i)
			s_col.append(j)
count = 0
rem = 0
for i in range(n):
	if i not in s_row:
		count += m
		rem += 1
for j in range(m):
	if j not in s_col:
		count += n - rem
print(count)


(a, b) = map(int, input().split())
row = []
column = []
for i in range(a):
	x = list(str(input()))
	if 'S' in x and i + 1 not in row:
		row.append(i + 1)
	for j in range(len(x)):
		if x[j] == 'S' and j + 1 not in column:
			column.append(j + 1)
print(a * b - len(row) * len(column))


(a, b) = map(int, input().split())
y = [0] * a
x = [0] * b
for i in range(a):
	f = input()
	if f.count('S') > 0:
		y[i] = 1
	for j in range(len(f)):
		if f[j].count('S') > 0:
			x[j] = 1
q = 0
cc = 0
for i in range(b):
	if x[i] != 1:
		q += a
		cc += 1
for i in range(a):
	if y[i] != 1:
		q += b - cc
print(q)


(n, m) = map(int, input().split())
grid = [input() for line in range(n)]
rows = len([line for line in grid if line == '.' * m])
cols = len([True for col in range(m) if len([row[col] for row in grid if row[col] == '.']) == n])
print(rows * m + cols * n - rows * cols)


(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) = map(int, input().split())
blockedCols = set()
blockedRows = set()
matrix = []
for i in range(r):
	row = input()
	matrix.append(row)
	for j in range(c):
		if row[j] == 'S':
			blockedRows.add(i)
			blockedCols.add(j)
res = 0
for i in range(r):
	for j in range(c):
		if i not in blockedRows or j not in blockedCols:
			res += 1
print(res)


(row, col) = map(int, input().split())
lst = []
cr = 0
cc = 0
for _ in range(row):
	s = input()
	if 'S' not in s:
		cr += 1
	lst.append(s)
for i in range(col):
	if 'S' not in [r[i] for r in lst]:
		cc += 1
print(row * cc + col * cr - cc * cr)


(x, y) = map(int, input().split())
l = 0
q = []
for i in range(x):
	a = input()
	if a.count('S') > 0:
		q.append(a)
	else:
		l = l + len(a)
f = 0
for i in range(y):
	for j in range(len(q)):
		if q[j][i] == 'S':
			f = 1
	if f != 1:
		l = l + len(q)
	f = 0
print(l)


import math
input1 = list(map(int, input().split()))
r = int(input1[0])
c = int(input1[1])
grid = []
total_s = 0
rows_eaten = 0
for row in range(0, r):
	new_row = []
	row_contains_s = False
	for char in input():
		new_row.append(char)
		if char.lower() == 's':
			row_contains_s = True
	if row_contains_s == False:
		total_s += c
		rows_eaten += 1
		new_row = []
		for char in range(0, c):
			new_row.append('x')
		grid.append(new_row)
	else:
		grid.append(new_row)
for col in range(0, c):
	col_contains_s = False
	number_of_eaten_already = 0
	for row in range(0, r):
		char = grid[row][col]
		if char.lower() == 's':
			col_contains_s = True
		if char.lower() == 'x':
			number_of_eaten_already += 1
	if col_contains_s == False:
		total_s += r - number_of_eaten_already
print(total_s)


size = list(map(int, input().split(' ')))
evil_strawberrys_rows = set()
evil_strawberrys_columns = set()
for i in range(size[0]):
	row = input()
	for j in range(size[1]):
		if row[j] == 'S':
			evil_strawberrys_rows.add(i)
			evil_strawberrys_columns.add(j)
answer = size[0] * size[1] - len(evil_strawberrys_rows) * len(evil_strawberrys_columns)
print(answer)


(r, c) = map(int, input().split())
cnt = 0
a = []
for i in range(r):
	s = input()
	a.append(s)
khordeshode = [[False for i in range(c)] for j in range(r)]
for i in range(r):
	if not 'S' in a[i]:
		for j in range(c):
			if not khordeshode[i][j]:
				cnt += 1
				khordeshode[i][j] = True
for i in range(c):
	hast = False
	for j in range(r):
		if a[j][i] == 'S':
			hast = True
			break
	if not hast:
		for j in range(r):
			if not khordeshode[j][i]:
				cnt += 1
				khordeshode[j][i] = True
print(cnt)


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


(X, Y) = map(int, input().split())
eat = 0
ate = 0
Lanes = []
for a in range(X):
	Lane = list(input())
	Lanes.append(Lane)
	if 'S' not in Lane:
		eat += Y
		ate += 1
for b in range(Y):
	stat = 0
	for c in range(X):
		if Lanes[c][b] == 'S':
			stat = 1
	if stat == 0:
		eat += X - ate
print(eat)


(r, c) = map(int, input().split())
all_seq = []
count_row_with_out_s = 0
count_col_with_out_s = 0
for i in range(r):
	row_input = input()
	all_seq.append(row_input)
for row in all_seq:
	if 'S' not in row:
		count_row_with_out_s += 1
for col in range(c):
	flag = True
	for row in range(r):
		if all_seq[row][col] == 'S':
			flag = False
			break
	if flag:
		count_col_with_out_s += 1
eatable_row_cells = count_row_with_out_s * c
eatable_col_cells = count_col_with_out_s * r - count_col_with_out_s * count_row_with_out_s
print(eatable_row_cells + eatable_col_cells)


(n, m) = map(int, input().split())
cake = [input() for i in range(n)]
A = [[1 for j in range(m)] for i in range(n)]
for i in range(n):
	for j in range(m):
		if cake[i][j] == 'S':
			A[i][j] = 2
c = 0
for i in range(n):
	k = 0
	for j in range(m):
		if A[i][j] == 1 and k >= 0:
			k += 1
		elif A[i][j] == 2:
			k = -1
	if k >= 0:
		c += k
		for j in range(m):
			A[i][j] = 0
for j in range(m):
	k = 0
	for i in range(n):
		if A[i][j] == 1 and k >= 0:
			k += 1
		elif A[i][j] == 2:
			k = -1
	if k >= 0:
		c += k
		for i in range(n):
			A[i][j] = 0
print(c)


(r, c) = map(int, input().split())
strawbery = []
for i in range(r):
	l = input()
	for j in range(c):
		if l[j] == 'S':
			strawbery.append((i, j))
hor = len({x for (x, y) in strawbery})
vert = len({x for (y, x) in strawbery})
eaten_hor = (r - hor) * c
eaten_ver = (c - vert) * hor
print(eaten_hor + eaten_ver)


(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)


(r, c) = map(int, input().split())
grid = [list(input()) for _ in range(r)]
(rows, cols) = (set(), set())
for i in range(r):
	for j in range(c):
		if grid[i][j] == 'S':
			rows.add(i)
			cols.add(j)
print(r * c - len(cols) * len(rows))


(r, c) = map(int, input().split())
row = set()
col = set()
for i in range(r):
	t = input()
	for j in range(c):
		if t[j] == 'S':
			row.add(i)
			col.add(j)
print(r * c - len(row) * len(col))


(n, k) = list(map(int, input().split()))
(m, o) = ([], [])
for i in range(n):
	c = list(input())
	for j in range(k):
		if c[j] == 'S':
			m.append(i)
			o.append(j)
e = len(set(m)) * len(set(o))
print(n * k - e)


import math
import sys
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)
(n, m) = mi()
a = []
for i in range(n):
	a.append(input())
r = c = 0
for i in range(n):
	if 'S' not in a[i]:
		r += 1
for i in range(m):
	if all((a[j][i] == '.' for j in range(n))):
		c += 1
print(r * m + c * n - r * c)


(n, m) = map(int, input().split())
l = [input() for i in range(n)]
r = 0
s = 0
for i in range(n):
	if set(l[i]) == {'.'}:
		r += 1
for i in range(m):
	se = set(l[0][i])
	for j in range(n):
		se |= set(l[j][i])
	if se == {'.'}:
		s += 1
print(r * m + s * n - s * r)


(r, c) = map(int, input().split())
cake = []
cc = [True for i in range(c)]
cr = [True for i in range(r)]
t = 0
for i in range(r):
	cake.append(input())
for row in range(r):
	for col in range(c):
		if cake[row][col] == 'S':
			cc[col] = False
			cr[row] = False
for i in range(r):
	for j in range(c):
		if cc[j] or cr[i]:
			t += 1
print(t)


(a, b) = map(int, input().split())
(s, p) = (0, [[0] * b for i in range(a)])
for i in range(a):
	t = input()
	if 'S' in t:
		for j in range(b):
			p[i][j] |= 1
			if t[j] == 'S':
				for k in range(a):
					p[k][j] |= 2
for i in range(a):
	s += p[i].count(3)
print(a * b - s)


(r, c) = map(int, input().split())
grid = [input() for _ in range(r)]
evilr = sum((any((k == 'S' for k in row)) for row in grid))
evilc = sum((any((k == 'S' for k in col)) for col in zip(*grid)))
print(r * c - evilr * evilc)


(n, m) = map(int, input().split())
z = []
for i in range(n):
	l = list(input())
	z.append(l)
cnt = 0
for i in z:
	if 'S' not in i:
		cnt += len(i)
		for j in range(len(i)):
			i[j] = '0'
h = []
for a in range(m):
	k = []
	for b in range(n):
		k.append(z[b][a])
	h.append(k)
for i in h:
	if 'S' not in i:
		cnt += i.count('.')
print(cnt)


(n, m) = map(int, input().split())
a = [list(input()) for i in range(n)]
(rows, columns) = (0, 0)
for i in range(n):
	if 'S' not in a[i]:
		for j in range(m):
			a[i][j] = 'A'
for i in range(m):
	if 'S' not in ''.join([a[j][i] for j in range(n)]):
		for j in range(n):
			a[j][i] = 'A'
print(''.join([''.join(i[:]) for i in a]).count('A'))


(r, c) = list(map(int, input().split()))
rs = [True] * r
cs = [True] * c
for i in range(r):
	s = input()
	for j in range(c):
		if s[j] == 'S':
			rs[i] = False
			cs[j] = False
ans = 0
for i in range(r):
	for j in range(c):
		ans += rs[i] or cs[j]
print(ans)


[r, c] = [int(i) for i in input().split()]
cake = []
fakecake = []
for x in range(r):
	s = input()
	cake.append(s)
	tmp = []
	for y in range(c):
		tmp.append(0)
	fakecake.append(tmp)
for a in range(r):
	evil = 0
	for b in range(c):
		if cake[a][b] == 'S':
			evil = 1
			break
	if evil == 0:
		for h in range(c):
			fakecake[a][h] = 1
for g in range(c):
	evil2 = 0
	for h in range(r):
		if cake[h][g] == 'S':
			evil2 = 1
			break
	if evil2 == 0:
		for k in range(r):
			fakecake[k][g] = 1
ans = 0
for e in range(r):
	for f in range(c):
		if fakecake[e][f] == 1:
			ans += 1
print(ans)


(r, c) = list(map(int, input().split()))
m = list()
ans = 0
for _ in range(r):
	m.append(input())
ans = sum((c for i in range(r) if 'S' not in m[i]))
for j in range(c):
	clean = True
	for i in range(r):
		if m[i][j] == 'S':
			clean = False
			break
	if clean:
		ans += r
		ans += sum((-1 for i in range(r) if 'S' not in m[i]))
print(ans)


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


(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))


import sys
rc = [int(x) for x in sys.stdin.readline().split()]
result = 0
col = []
row = []
ccol = 0
for i in range(rc[0]):
	t = list(sys.stdin.readline())
	for j in range(len(t) - 1):
		if t[j] == 'S':
			ccol += 1
			col.append(j)
	if ccol > 0:
		row.append(i)
		ccol = 0
col = list(set(col))
col.sort()
lr = len(row)
lc = len(col)
if lc == 0 and lr == 0:
	print(rc[0] * rc[1])
	exit()
c = 0
i = 0
cnt = 0
while c < rc[0]:
	if row[i] == c:
		if i < lr - 1:
			i += 1
	else:
		cnt += 1
		result += rc[1]
	c += 1
d = 0
j = 0
while d < rc[1]:
	if col[j] == d:
		if j < lc - 1:
			j += 1
	else:
		result += rc[0] - cnt
	d += 1
print(result)


(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, m) = map(int, input().split())
x = []
y = ['n'] * m
(b, c, d, e) = (0, 0, 0, 0)
for i in range(n):
	x += [list(str(input()))]
for j in range(n):
	for k in range(m):
		if x[j][k] == '.':
			b += 1
		if b == m:
			c += m
			x[j] = y
	b = 0
for j in range(m):
	for k in range(n):
		if x[k][j] == '.':
			d += 1
		elif x[k][j] == 'n':
			e += 1
		if d + e == n:
			c += d
	d = 0
	e = 0
print(c)


(r, c) = [int(x) for x in input().split()]
row = [0 for i in range(r)]
col = [0 for i in range(c)]
for i in range(r):
	s = input()
	for j in range(c):
		if s[j] == 'S':
			row[i] = 1
			col[j] = 1
cnt = 0
for i in range(r):
	for j in range(c):
		if row[i] == 0 or col[j] == 0:
			cnt += 1
print(cnt)


temp = [int(x) for x in input().split()]
r = temp[0]
c = temp[1]
g = []
for i in range(r):
	g.append(input())
checked = [[True for x in range(c)] for x in range(r)]
for i in range(r):
	if 'S' in g[i]:
		for j in range(c):
			checked[i][j] = False
		x = g[i].index('S')
for i in range(c):
	bool = False
	for j in range(r):
		if g[j][i] == 'S':
			bool = True
			break
	if not bool:
		for k in range(r):
			checked[k][i] = True
result = 0
for x in checked:
	result += x.count(True)
print(result)


(a, b) = map(int, input().split())
l = []
c = r = 0
for _ in range(a):
	k = list(input())
	l.append(k)
y = []
for i in range(a):
	if l[i].count('.') == b:
		c += b
	else:
		y.append(l[i])
if len(y) == 0:
	print(c)
	exit()
l2 = [[row[i] for row in y] for i in range(len(y[0]))]
for i in l2:
	if i.count('.') == len(i):
		r += len(i)
print(c + r)


(r, c) = map(int, input().split())
cells = 0
eaten = 0
columns = [-1] * c
for i in range(r):
	strawberry = 0
	left_ind = 0
	line = input()
	found = line.find('S', left_ind)
	while found != -1:
		columns[found] = 1
		left_ind = found + 1
		found = line.find('S', left_ind)
		strawberry += 1
	if strawberry == 0:
		eaten += 1
print(eaten * c + (c - columns.count(1)) * (r - eaten))


b = [int(b) for b in input().split()]
r = b[0]
c = b[1]
e = []
for i in range(b[0]):
	d = [d for d in input()]
	e.append(d)
sumr = 0
sumc = 0
for j in range(c):
	for i in range(r):
		k = 0
		if e[i][j] == 'S':
			k = 1
			break
	if k == 0:
		sumc = sumc + 1
for i in range(r):
	for j in range(c):
		q = 0
		if e[i][j] == 'S':
			q = 1
			break
	if q == 0:
		sumr = sumr + 1
print(sumc * r + sumr * c - sumr * sumc)


ar = []
for i in input().split(' '):
	ar.append(int(i))
matrix = [[0 for col in range(ar[1])] for row in range(ar[0])]
count = 0
row_totals = []
for i in range(ar[0]):
	temp = input()
	ch = 0
	for j in range(len(temp)):
		if temp[j] == 'S':
			matrix[i][j] = 1
			ch = 1
	if ch == 0:
		row_totals.append(0)
	else:
		row_totals.append(1)
col_totals = [sum(x) for x in zip(*matrix)]
for i in range(len(matrix)):
	for j in range(len(matrix[i])):
		if row_totals[i] == 0 or col_totals[j] == 0:
			count = count + 1
print(count)


from operator import itemgetter
(r, c) = map(int, input().split())
field = [input() for i in range(r)]
num = r * c
fieldr = [0] * r
fieldc = [0] * c
for i in range(r):
	for j in range(c):
		if field[i][j] == 'S':
			fieldr[i] = 1
			fieldc[j] = 1
			num -= 1
for i in range(r):
	for j in range(c):
		if field[i][j] != 'S':
			if fieldr[i] == fieldc[j] and fieldr[i] == 1:
				num -= 1
print(num)


(r, c) = list(map(int, input().split()))
(row, col) = ([], [])
for i in range(r):
	grid_row = input()
	for (j, ch) in enumerate(grid_row):
		if ch == 'S':
			row.append(i)
			col.append(j)
row = len(set(row))
col = len(set(col))
eat_row = r - row
eat_col = c - col
eatable = eat_row * c + eat_col * r - eat_col * eat_row
print(eatable)


(r, c) = [int(i) for i in input().split()]
(evilStrawberryColum, evilStrawberryRow, cakeStrings) = (set(), set(), [])
for i in range(0, r):
	cakeStrings.append(input())
	if cakeStrings[i].count('S'):
		[(evilStrawberryRow.add(i), evilStrawberryColum.add(j)) for j in range(0, c) if cakeStrings[i][j] == 'S']
pieces = r * c - len(evilStrawberryRow) * len(evilStrawberryColum)
print(pieces)


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())
P = 1000000007
(n, m) = In()
arr = [0 for i in range(m)]
c = 0
for i in range(n):
	s = input()
	if s == '.' * m:
		c += m
	else:
		for i in range(m):
			if s[i] == '.':
				arr[i] += 1
temp = c
for i in range(m):
	if arr[i] == n - temp // m:
		c += arr[i]
print(c)


(r, c) = [int(num) for num in input().split(' ')]
map = []
for i in range(r):
	row = [ch for ch in input()]
	map.append(row)
ans = 0
for i in range(r):
	if 'S' not in map[i]:
		for j in range(c):
			if map[i][j] == '.':
				map[i][j] = '*'
				ans += 1
for i in range(c):
	cnt = 0
	isFind = False
	for j in range(r):
		if map[j][i] == 'S':
			isFind = True
			break
		if map[j][i] == '.':
			cnt += 1
	if isFind == False:
		ans += cnt
print(ans)


(r, c) = map(int, input().split())
cake = []
for i in range(r):
	cake.append(input())
nal = 0
nar = 0
rows = {i: [] for i in range(c)}
for i in cake:
	for j in range(c):
		rows[j].append(i[j])
for i in cake:
	if 'S' in i:
		nal += 1
for i in rows.values():
	if 'S' in i:
		nar += 1
print(r * c - nal * nar)


(r, c) = map(int, input().split())
l = list()
ans = set()
result = 0
for i in range(r):
	l.append(list(input()))
for i in range(r):
	if 'S' in l[i]:
		k = 'Do Nothing'
	else:
		result += c
		for j in range(c):
			ans.add(str(i) + ' ' + str(j))
for i in range(c):
	cnt = 0
	for j in range(r):
		if l[j][i] == 'S':
			break
		cnt += 1
	if cnt == r:
		for j in range(r):
			temp = str(j) + ' ' + str(i)
			if temp not in ans:
				result += 1
print(result)