A. Cakeminator

problem_index: A

time_limit: 1 second

memory_limit: 256 megabytes

note:
For the first example, one possible way to eat the maximum number of cake cells is as follows (perform 3 eats).
![image](images/cf_330_A/2.png)
![image](images/cf_330_A/3.png)
![image](images/cf_330_A/4.png)

solutions: ["def solve(cake):\n\t(rows, collumns) = (set(), set())\n\tfor (i, row) in enumerate(cake):\n\t\tfor (j, cell) in enumerate(row):\n\t\t\tif cell == 'S':\n\t\t\t\trows.add(i)\n\t\t\t\tcollumns.add(j)\n\tres = 0\n\tfor (i, row) in enumerate(cake):\n\t\tfor (j, cell) in enumerate(row):\n\t\t\tif cell == 'S':\n\t\t\t\tcontinue\n\t\t\tif i not in rows or j not in collumns:\n\t\t\t\tres += 1\n\treturn res\n(r, c) = map(int, input().split())\nl = []\nfor _ in range(r):\n\tl.append(input())\nprint(solve(l))\n", "(a, b) = list(map(int, input().split()))\nu = 0\nt = []\nfor i in range(a):\n\tt.append(list(input()))\nfor j in t:\n\tif 'S' in j:\n\t\tpass\n\telse:\n\t\tfor k in range(len(j)):\n\t\t\tj[k] = 'a'\n\t\t\tu += 1\nfor m in range(b):\n\ty = []\n\tfor l in range(a):\n\t\ty.append(t[l][m])\n\tif 'S' not in y:\n\t\tfor e in range(len(y)):\n\t\t\tif y[e] == '.':\n\t\t\t\tu += 1\n\t\t\t\ty[e] = 'a'\nprint(u)\n", "(r, c) = [int(s) for s in input().split(' ')]\nrows = []\nr_cnt = 0\nc_cnt = 0\nfor i in range(r):\n\trow = input()\n\tif row == '.' * c:\n\t\tr_cnt += 1\n\trows.append(row)\nfor j in range(c):\n\tcol = [rows[k][j] for k in range(r)]\n\tif col == ['.'] * r:\n\t\tc_cnt += 1\nprint(r_cnt * c + c_cnt * (r - r_cnt))\n", "(x, y) = map(int, input().split())\ngrid = []\nfor i in range(x):\n\tline = list(input())\n\tgrid.append(line)\nC = 0\nfor i in range(x):\n\tif 'S' not in grid[i]:\n\t\tC += y\n\t\tgrid[i] = [1] * y\nfor i in range(y):\n\ttemp = x\n\tfor j in range(x):\n\t\tif grid[j][i] == 'S':\n\t\t\tbreak\n\t\telif grid[j][i] == 1:\n\t\t\ttemp -= 1\n\telse:\n\t\tC += temp\nprint(C)\n", "(r, c) = [int(i) for i in input().split(' ')]\nls = list()\nfor i in range(r):\n\tls_ = [-(c + r) if s == 'S' else 1 for s in input()]\n\tls.append(ls_)\nresult = 0\nfor i in range(r):\n\tsum_ = sum([s_ for s_ in ls[i]])\n\tif sum_ < 0:\n\t\tcontinue\n\tresult += sum_\n\tfor j in range(c):\n\t\tif ls[i][j] >= 0:\n\t\t\tls[i][j] = 0\nfor i in range(c):\n\tsum_ = sum([ls[s_][i] for s_ in range(r)])\n\tif sum_ < 0:\n\t\tcontinue\n\tresult += sum_\n\tfor j in range(r):\n\t\tif ls[j][i] >= 0:\n\t\t\tls[j][i] = 0\nprint(result)\n", "(r, c) = map(int, input().split())\ntort = []\nschet = 0\npodschet_f = 0\npodschet = 0\nstolb = 0\nstrok = 0\nfor i in range(r):\n\ttort.append(list(str(input())))\nfor i in range(r):\n\tfor j in range(c):\n\t\tif tort[i][j] != 'S':\n\t\t\tpodschet_f += 1\n\t\telse:\n\t\t\tpodschet_f = 0\n\tif podschet_f == c:\n\t\tschet += podschet_f\n\t\tpodschet_f = 0\n\t\tstrok += 1\n\telse:\n\t\tpodschet_f = 0\nfor j in range(c):\n\tfor i in range(r):\n\t\tif tort[i][j] != 'S':\n\t\t\tpodschet += 1\n\t\telse:\n\t\t\tpodschet = 0\n\tif podschet == r:\n\t\tschet += podschet\n\t\tpodschet = 0\n\t\tstolb += 1\n\telse:\n\t\tpodschet = 0\nif strok >= stolb and stolb >= 1:\n\tprint(schet - stolb * strok)\nelif stolb >= strok and strok >= 1:\n\tprint(schet - stolb * strok)\nelif r == strok and c == stolb:\n\tprint(r * c)\nelse:\n\tprint(schet)\n", "(n, m) = map(int, input().split())\nc = []\na = [0] * n\nb = [0] * m\nfor i in range(n):\n\tc.append(input())\nfor i in range(n):\n\tfor j in range(m):\n\t\tif c[i][j] == '.':\n\t\t\tb[j] += 1\n\t\t\ta[i] += 1\nd = m * a.count(m)\nd += n * b.count(n)\nd = d - a.count(m) * b.count(n)\nprint(d)\n", "(r, c) = map(int, input().strip().split())\nl = []\nR = 0\nC = 0\nfor i in range(r):\n\tl.append(input())\n\tif l[i].find('S', 0) == -1:\n\t\tR += 1\nfor i in range(c):\n\tt = []\n\tfor j in range(r):\n\t\tt.append(l[j][i])\n\tT = ''.join(t)\n\tif T.find('S', 0) == -1:\n\t\tC += 1\nprint(r * c - (r - R) * (c - C))\n", "I = lambda : map(int, input().split())\n(n, m) = I()\ncakearray = [input() for i in range(n)]\nrowcells = len([0 for s in cakearray if 'S' not in s])\ncollcells = 0\nfor i in range(m):\n\ttemp = 0\n\tfor j in range(n):\n\t\tif cakearray[j][i] == 'S':\n\t\t\ttemp = 0\n\t\t\tbreak\n\t\telse:\n\t\t\ttemp = 1\n\tcollcells += temp\nprint(rowcells * m + (collcells * n - rowcells * collcells))\n", "(r, c) = map(int, input().split())\n(q, w) = (0, 0)\nfor i in range(r):\n\ts = input().replace('.', '0').replace('S', '1')\n\tif '1' not in s:\n\t\tq += c\n\t\tr -= 1\n\tw = w | int(s, 2)\nw = bin(w)[2:]\nprint(q + r * (w.count('0') + c - len(w)))\n", "z = list(map(int, input().split()))\nn = []\nm = []\nfor i in range(z[0]):\n\tx = list(input().split())\n\tfor u in x:\n\t\tn.append(u)\nc = 0\nfor i in range(z[1]):\n\td = 0\n\tfor o in n:\n\t\tm.append(o[c])\n\t\td = d + 1\n\t\tif d == z[0]:\n\t\t\tc = c + 1\na = []\nfor i in n:\n\ts = 0\n\tfor o in i:\n\t\ts = s + 1\n\t\tif o == 'S':\n\t\t\ts = 0\n\t\t\tbreak\n\t\telif s == z[1]:\n\t\t\ta.append(s)\nv = 0\nb = 0\nl = []\nfor i in m:\n\tv = v + 1\n\tb = b + 1\n\tif i == 'S':\n\t\tb = 0\n\tif b == z[0]:\n\t\tif a != []:\n\t\t\tl.append(b - len(a))\n\t\telse:\n\t\t\tl.append(b)\n\tif v == z[0]:\n\t\tb = 0\n\t\tv = 0\np = l + a\nqw = 0\nfor i in p:\n\tqw = qw + i\nprint(qw)\n", "(r, c) = map(int, input().split())\nmatrix = []\nres = 0\nfor i in range(r):\n\tmatrix.append(input())\nfor i in range(r):\n\tfor j in range(c):\n\t\tf = True\n\t\tg = True\n\t\tif matrix[i][j] == '.':\n\t\t\tfor k in range(c):\n\t\t\t\tif matrix[i][k] == 'S':\n\t\t\t\t\tf = False\n\t\t\t\t\tbreak\n\t\t\tfor l in range(r):\n\t\t\t\tif matrix[l][j] == 'S':\n\t\t\t\t\tg = False\n\t\t\t\t\tbreak\n\t\t\tif f or g:\n\t\t\t\tres += 1\nprint(res)\n", "from pprint import pprint\n(r, c) = map(int, input().split())\nvals = []\nfor _ in range(r):\n\tvals.append(input())\nres = 0\nfor i in range(r):\n\tif 'S' not in vals[i]:\n\t\tres += vals[i].count('.')\n\t\tvals[i] = '*' * len(vals[i])\nvals_rotated = list(zip(*vals[::-1]))\nfor i in range(c):\n\tif 'S' not in vals_rotated[i]:\n\t\tres += vals_rotated[i].count('.')\nprint(res)\n", "(r, t) = map(int, input().split())\nw = []\nd = 0\nl = 0\nh = 0\nm = [0] * 100\nfor i in range(r):\n\ts = input()\n\tc = 0\n\tf = 0\n\tfor j in range(len(s)):\n\t\tw.insert(j, s[j])\n\t\tif w[j] == '.' and f != 1:\n\t\t\tc = c + 1\n\t\telif w[j] == 'S':\n\t\t\tc = 0\n\t\t\tf = 1\n\t\t\tif m[j] != -1:\n\t\t\t\td = d + 1\n\t\t\t\tm[j] = -1\n\tl = l + c\n\tif c != 0:\n\t\th = h + 1\nprint(l + (t - d) * (r - h))\n", "(r, c) = map(int, input().split())\ns_r = set()\ns_c = set()\nt = 0\nt_r = 0\nfor i in range(r):\n\ts = input()\n\tfor j in range(c):\n\t\tif s[j] == 'S':\n\t\t\tif i not in s_r:\n\t\t\t\ts_r.add(i)\n\t\t\t\tt_r += 1\n\t\t\ts_c.add(j)\nfor i in range(r):\n\tif i not in s_r:\n\t\tt += c\nfor j in range(c):\n\tif j not in s_c:\n\t\tt += t_r\nprint(t)\n", "(r, c) = input().split(' ')\nr = int(r)\nc = int(c)\ncount = 0\nmatrix = [[None] * c] * r\nfor x in range(r):\n\tmatrix[x] = list(input())\nfor x in range(r):\n\tif 'S' in matrix[x]:\n\t\tpass\n\telse:\n\t\tfor y in range(len(matrix[x])):\n\t\t\tif matrix[x][y] is not None:\n\t\t\t\tcount += 1\n\t\t\t\tmatrix[x][y] = None\nfor y in range(c):\n\trunning = 0\n\tfor x in range(r):\n\t\tif matrix[x][y] == 'S':\n\t\t\trunning = 0\n\t\t\tbreak\n\t\telif matrix[x][y] is not None:\n\t\t\trunning += 1\n\t\t\tmatrix[x][y] = None\n\tcount += running\nprint(count)\n", "(r, c) = map(int, input().split())\nR = [0] * r\nC = [0] * c\nfor i in range(r):\n\ts = input()\n\tif s.count('S') > 0:\n\t\tR[i] = 1\n\tfor j in range(c):\n\t\tif s[j] == 'S':\n\t\t\tC[j] = 1\nprint(c * r - (r - R.count(0)) * (c - C.count(0)))\n", "def solve(x, y, a, n, m):\n\tfor j in range(m):\n\t\tif a[x][j] == 'S':\n\t\t\tfor i in range(n):\n\t\t\t\tif a[i][y] == 'S':\n\t\t\t\t\treturn 0\n\treturn 1\n(n, m) = map(int, input().split())\na = []\nfor z in range(n):\n\ta.append(list(input()))\ncake = 0\nfor i in range(n):\n\tfor j in range(m):\n\t\tcake += solve(i, j, a, n, m)\nprint(cake)\n", "def main():\n\t(r, c) = input().split(' ')\n\tcake = []\n\teat = 0\n\teliminate = []\n\tfor i in range(int(r)):\n\t\trow = input()\n\t\trow = list(row)\n\t\tcake.append(row)\n\tfor i in range(int(r)):\n\t\tevilstrwbr = 0\n\t\tfor j in range(int(c)):\n\t\t\tif cake[i][j] == 'S':\n\t\t\t\tevilstrwbr += 1\n\t\tif evilstrwbr == 0:\n\t\t\teliminate.append(i)\n\twhile len(eliminate) != 0:\n\t\tindice = eliminate.pop()\n\t\tdel cake[indice]\n\t\teat = eat + int(c)\n\tif not cake:\n\t\tprint(eat)\n\telse:\n\t\tfor i in range(len(cake[0])):\n\t\t\tevilstrwbr = 0\n\t\t\tfor j in range(len(cake)):\n\t\t\t\tif cake[j][i] == 'S':\n\t\t\t\t\tevilstrwbr += 1\n\t\t\tif evilstrwbr == 0:\n\t\t\t\teliminate.append(i)\n\t\twhile len(eliminate) != 0:\n\t\t\tindice = eliminate.pop()\n\t\t\tfor i in range(len(cake)):\n\t\t\t\tdel cake[i][indice]\n\t\t\teat = eat + len(cake)\n\t\tprint(eat)\nmain()\n", "(r, c) = map(int, input().split())\na = []\nb = []\nfor i in range(r):\n\tl = list(input())\n\tfor j in range(c):\n\t\tif l[j] == 'S':\n\t\t\ta.append(i)\n\t\t\tb.append(j)\nprint(r * c - len(list(set(a))) * len(list(set(b))))\n", "from sys import stdin, stdout\nfrom math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log\nfrom collections import defaultdict as dd, deque\nfrom heapq import merge, heapify, heappop, heappush, nsmallest\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\nmod = pow(10, 9) + 7\nmod2 = 998244353\n\ndef inp():\n\treturn stdin.readline().strip()\n\ndef iinp():\n\treturn int(inp())\n\ndef out(var, end='\\n'):\n\tstdout.write(str(var) + '\\n')\n\ndef outa(*var, end='\\n'):\n\tstdout.write(' '.join(map(str, var)) + end)\n\ndef lmp():\n\treturn list(mp())\n\ndef mp():\n\treturn map(int, inp().split())\n\ndef smp():\n\treturn map(str, inp().split())\n\ndef l1d(n, val=0):\n\treturn [val for i in range(n)]\n\ndef l2d(n, m, val=0):\n\treturn [l1d(m, val) for j in range(n)]\n\ndef remadd(x, y):\n\treturn 1 if x % y else 0\n\ndef ceil(a, b):\n\treturn (a + b - 1) // b\n\ndef isprime(x):\n\tif x <= 1:\n\t\treturn False\n\tif x in (2, 3):\n\t\treturn True\n\tif x % 2 == 0:\n\t\treturn False\n\tfor i in range(3, int(sqrt(x)) + 1, 2):\n\t\tif x % i == 0:\n\t\t\treturn False\n\treturn True\n(n, m) = mp()\nml = [inp() for i in range(n)]\ntn = n\nans = 0\nfor i in range(n):\n\tif 'S' not in ml[i]:\n\t\ttn -= 1\n\t\tans += m\nfor i in range(m):\n\tc = 0\n\tfor j in range(n):\n\t\tif ml[j][i] == 'S':\n\t\t\tc += 1\n\tif c == 0:\n\t\tans += tn\nprint(ans)\n", "a = list(map(int, input().strip().split()))\nr = a[0]\nc = a[1]\na = []\nfor i in range(r):\n\tb = input()\n\ta.append(b)\ns = 0\np = 0\nfor i in range(0, r):\n\tq = 0\n\tfor j in range(0, c):\n\t\tif a[i][j] == 'S':\n\t\t\tq = q + 1\n\tif q == 0:\n\t\ts = s + c\n\t\tp = p + 1\nfor i in range(0, c):\n\tq = 0\n\tfor j in range(0, r):\n\t\tif a[j][i] == 'S':\n\t\t\tq = q + 1\n\tif q == 0:\n\t\ts = s + r - p\nprint(s)\n", "from collections import deque, Counter\nimport array\nfrom itertools import combinations, permutations\nfrom math import sqrt\nimport unittest\n\ndef read_int():\n\treturn int(input().strip())\n\ndef read_int_array():\n\treturn [int(i) for i in input().strip().split(' ')]\n(rows, cols) = read_int_array()\nfield = [input().strip() for _ in range(rows)]\nrows_taken = 0\nfor r in range(rows):\n\trows_taken += 1 if 'S' not in field[r] else 0\ncount = rows_taken * cols\nfor c in range(cols):\n\tcount += rows - rows_taken if 'S' not in (field[r][c] for r in range(rows)) else 0\nprint(count)\n", "(r, c) = map(int, input().split())\na = []\nfor i in range(r):\n\ts = input()\n\ts = list(s)\n\ta.append(s)\nrow = 0\nfor i in a:\n\tif 'S' in i:\n\t\trow += 1\n\t\tcontinue\nb = []\nfor i in range(c):\n\ttemp = []\n\tfor j in range(r):\n\t\ttemp.append(0)\n\tb.append(temp)\nfor i in range(r):\n\tfor j in range(c):\n\t\tb[j][i] = a[i][j]\ncol = 0\nfor i in b:\n\tif 'S' in i:\n\t\tcol += 1\n\t\tcontinue\nprint(r * c - row * col)\n", "(r, c) = list(map(int, input().strip().split(' ')))\ng = []\nfor i in range(0, r):\n\ts = list(input().strip())\n\tg.append(s)\nt = g[:]\nfor i in range(0, r):\n\tbj = True\n\tfor j in range(0, c):\n\t\tif g[i][j] == 'S':\n\t\t\tbj = False\n\tif bj:\n\t\tfor k in range(0, c):\n\t\t\tt[i][k] = '0'\nfor i in range(0, c):\n\tbj = True\n\tfor j in range(0, r):\n\t\tif g[j][i] == 'S':\n\t\t\tbj = False\n\tif bj:\n\t\tfor k in range(0, r):\n\t\t\tt[k][i] = '0'\ns = 0\nfor i in range(0, r):\n\tfor j in range(0, c):\n\t\tif t[i][j] == '0':\n\t\t\ts += 1\nprint(str(s))\n", "def run():\n\t(r, c) = [int(_) for _ in input().split()]\n\tlines = [input() for i in range(r)]\n\tnum_rows = [1 if 'S' in i else 0 for i in lines]\n\timport math\n\tnum_rows = sum(num_rows)\n\tnum_rows = sum([0 if 'S' in i else 1 for i in lines])\n\tnum_cols = 0\n\tfor j in range(c):\n\t\tfound = False\n\t\tfor i in range(r):\n\t\t\tif lines[i][j] == 'S':\n\t\t\t\tfound = True\n\t\tif not found:\n\t\t\tnum_cols += 1\n\treturn num_cols * r - num_rows * num_cols + num_rows * c\nprint(run())\n", "(r, c) = map(int, input().split())\nrow = list(range(r))\ncol = list(range(c))\nfor i in range(r):\n\tcl = input()\n\tfor j in range(c):\n\t\tif cl[j] == 'S':\n\t\t\tif i in row:\n\t\t\t\trow.remove(i)\n\t\t\tif j in col:\n\t\t\t\tcol.remove(j)\nans = len(row) * c + len(col) * r - len(row) * len(col)\nprint(ans)\n", "(r, c) = map(int, input().split())\nrow = [0] * r\ncol = [0] * c\narr = []\nfor i in range(r):\n\tarr.append(input())\nfor i in range(r):\n\tfor j in range(c):\n\t\tif arr[i][j] == 'S':\n\t\t\tcol[j] += 1\n\t\t\trow[i] += 1\nccol = 0\ncrow = 0\nfor x in row:\n\tif x == 0:\n\t\tcrow += 1\nfor x in col:\n\tif x == 0:\n\t\tccol += 1\nprint(c * crow + r * ccol - ccol * crow)\n", "(row, col) = [int(x) for x in input().split()]\ncake = []\nfor _ in range(row):\n\tcake.append([x for x in input()])\nr = [s for s in cake if s.count('S')]\nv = [s for s in zip(*cake) if s.count('S')]\nprint(row * col - len(r) * len(v))\n", "x = [int(n) for n in input().split()]\nl = 0\ns = []\nfor k in range(x[0]):\n\ts.append([n for n in input()])\niu = 0\nfor n in range(len(s)):\n\tif s[n].count('S') == 0:\n\t\tl += len(s[n])\n\t\tiu = 1\n\t\tfor k in range(len(s[n])):\n\t\t\ts[n][k] = 'a'\n\telse:\n\t\tiu = 0\n\t\tcontinue\npp = []\nfor n in range(len(s[0])):\n\tfor k in range(len(s)):\n\t\tif s[k][n] == 'S':\n\t\t\tpp.append(n)\n\t\t\tbreak\n\t\telse:\n\t\t\tcontinue\nfor n in range(len(s[0])):\n\tif pp.count(n) == 0:\n\t\tfor k in range(len(s)):\n\t\t\tif s[k][n] != 'a':\n\t\t\t\tl += 1\n\telse:\n\t\tcontinue\nprint(l)\n", "Coordinat = input().split()\nClst = []\nRlst = []\nfor x in range(int(Coordinat[0])):\n\tfor (index, y) in enumerate(input()):\n\t\tif 'S' == y:\n\t\t\tClst.append(index)\n\t\t\tRlst.append(x)\nprint(int(Coordinat[0]) * int(Coordinat[1]) - len(set(Clst)) * len(set(Rlst)))\n", "(a, b) = map(int, input().split())\nlist1 = [input() for i in range(a)]\nprint(a * b - len([1 for i in list1 if i.count('S')]) * len([1 for j in zip(*list1) if j.count('S')]))\n", "(r, c) = map(int, input().split())\nl = []\nfor i in range(r):\n\ts = str(input())\n\ta = list(s)\n\tl.append(s)\nans = 0\nls = ['*' for i in range(c)]\nfor i in range(r):\n\tif 'S' not in l[i]:\n\t\tans += c\n\t\tl[i] = ls\nfor i in range(c):\n\tb = []\n\tfor j in range(r):\n\t\tb.append(l[j][i])\n\tif 'S' not in b:\n\t\tans += b.count('.')\nprint(ans)\n", "def fun(n, m, li):\n\teatrow = []\n\tnoteatcolumn = []\n\tfor i in range(n):\n\t\tfi = []\n\t\tfor j in range(m):\n\t\t\tif li[i][j] == 'S':\n\t\t\t\tfi.append(j)\n\t\tif len(fi) > 0:\n\t\t\tnoteatcolumn.extend(fi)\n\t\t\tcontinue\n\t\telse:\n\t\t\teatrow.extend([(i, j) for j in range(m)])\n\teat = set(range(m)) - set(noteatcolumn)\n\tfor j in eat:\n\t\teatrow.extend([(i, j) for i in range(n)])\n\tprint(len(set(eatrow)))\n(n, m) = list(map(lambda x: int(x), input().split()))\nli = [input() for i in range(n)]\nfun(n, m, li)\n", "(x, y) = map(int, input().split())\n(r, c) = (0, [])\nfor i in range(x):\n\tl = input()\n\tfor k in range(len(l)):\n\t\tif l[k] == 'S':\n\t\t\tc.append(k)\n\tif 'S' in l:\n\t\tr += 1\nprint(x * y - r * len(set(c)))\n", "(r, c) = str(input()).split()\nr = int(r)\nc = int(c)\nface = list()\nfor i in range(r):\n\tline = str(input())\n\ttemp_list = list()\n\tfor j in range(c):\n\t\tif line[j] == 'S':\n\t\t\ttemp_list.append(1)\n\t\telse:\n\t\t\ttemp_list.append(0)\n\tface.append(temp_list)\nvalue = 0\nfor i in range(r):\n\tflag = True\n\tfor j in range(c):\n\t\tif face[i][j] > 0:\n\t\t\tflag = False\n\t\t\tbreak\n\tif flag:\n\t\tvalue += c\n\t\tfor j in range(c):\n\t\t\tface[i][j] = -1\nfor j in range(c):\n\tnum = 0\n\tflag = True\n\tfor i in range(r):\n\t\tif face[i][j] > 0:\n\t\t\tflag = False\n\t\t\tbreak\n\t\tif face[i][j] == 0:\n\t\t\tnum += 1\n\tif flag:\n\t\tvalue += num\nprint(value)\n", "def inpNum():\n\treturn int(input())\n\ndef inpNums():\n\treturn map(int, input().split())\n\ndef inpList():\n\treturn list(map(int, input().split()))\n\ndef inpStrMatrix(rows):\n\treturn [list(input()) for _ in range(rows)]\n(r, c) = inpNums()\nmat = inpStrMatrix(r)\nrs = set()\ncs = set()\nfor _r in range(r):\n\tfor _c in range(c):\n\t\tif mat[_r][_c] == 'S':\n\t\t\trs.add(_r)\n\t\t\tcs.add(_c)\nt = 0\nleft_rows = r - len(rs)\nleft_cols = c - len(cs)\nt += left_rows * c\nt += left_cols * r - left_rows * left_cols\nprint(t)\n", "(r, c) = map(int, input().split())\na = []\nb = []\nfor i in range(r):\n\ta.append(input())\nfor i in range(r):\n\tif 'S' not in a[i]:\n\t\ta[i] = 'X' * c\nfor j in range(c):\n\tc = []\n\tfor i in range(r):\n\t\tc.append(a[i][j])\n\tb.append(c)\nfor i in range(len(b)):\n\tif 'S' not in b[i]:\n\t\tfor j in range(r):\n\t\t\tb[i][j] = 'X'\nk = 0\nfor i in range(len(b)):\n\tfor j in range(r):\n\t\tif b[i][j] == 'X':\n\t\t\tk += 1\nprint(k)\n", "(rows, columns) = map(int, input().split())\ncake = []\nans = 0\nfor i in range(rows):\n\tcake.append(input())\nwhile columns * '.' in cake:\n\tans += columns\n\tcake.remove(columns * '.')\n\trows -= 1\ncake = [''.join(a) for a in zip(*cake)]\nwhile rows * '.' in cake:\n\tans += rows\n\tcake.remove(rows * '.')\nprint(ans)\n", "import sys\n\nclass Cake:\n\n\tdef __init__(self, row, col, ca):\n\t\tself.r = row\n\t\tself.c = col\n\t\tself.cell = ca\n\n\tdef show(self):\n\t\tfor i in range(self.r):\n\t\t\tprint(self.cell[i])\n\n\tdef calCell(self):\n\t\tcountRow = 0\n\t\tfor x in self.cell:\n\t\t\tif x == '.' * self.c:\n\t\t\t\tcountRow += 1\n\t\tcountColCell = 0\n\t\tfor i in range(self.c):\n\t\t\tisS = False\n\t\t\tfor j in self.cell:\n\t\t\t\tif j[i] != '.':\n\t\t\t\t\tisS = True\n\t\t\tif isS is False:\n\t\t\t\tcountColCell += self.r - countRow\n\t\treturn countColCell + countRow * self.c\n\ndef main():\n\t(r, c) = [int(x) for x in sys.stdin.readline().split()]\n\tcake = []\n\tfor x in range(r):\n\t\tcake.append(sys.stdin.readline().strip())\n\tboard = Cake(r, c, cake)\n\tprint(board.calCell())\nmain()\n", "(n, m) = map(int, input().split())\na = []\n[a.append(input()) for i in range(n)]\nstroki = 0\nstolb = 0\nb = []\nfor j in range(m):\n\tbb = []\n\tfor i in range(n):\n\t\t[bb.append(a[i][j])]\n\tb.append(' '.join(bb))\nfor ss in a:\n\tif 'S' not in ss:\n\t\tstroki += 1\nfor pp in b:\n\tif 'S' not in pp:\n\t\tstolb += 1\ncc = []\nfor i in a:\n\tfor j in i:\n\t\tcc.append(j)\nif 'S' not in cc:\n\tsumma = n * m\nelif stroki == stolb:\n\tsumma = stroki * m + stolb * n - max(stroki, stolb) * max(stroki, stolb)\nelif stroki != 0 or stolb != 0:\n\tsumma = stroki * m + stolb * n - max(stroki, stolb) * min(stroki, stolb)\nprint(summa)\n", "(a, b) = list(map(int, input().split()))\nm = []\nfor i in range(a):\n\tm.append(list(input()))\nc = 0\nfor i in range(a):\n\tfor j in range(b):\n\t\tif 'S' not in m[i]:\n\t\t\tc += 1\n\t\t\tm[i][j] = '0'\n\t\telse:\n\t\t\tbreak\nim = []\nim += [0] * b\nfor i in range(b):\n\tim[i] = [0] * a\n\tfor j in range(a):\n\t\tim[i][j] = m[j][i]\nfor i in range(b):\n\tfor j in range(a):\n\t\tif 'S' not in im[i]:\n\t\t\tif '.' in im[i][j]:\n\t\t\t\tc += 1\n\t\t\t\tim[i][j] = '0'\n\t\telse:\n\t\t\tbreak\nprint(c)\n", "s = input().split()\nr = int(s[0])\nc = int(s[1])\na = []\nfor i in range(r):\n\ta.append(input())\nrow = r\ncol = c\nfor s in a:\n\tfor x in s:\n\t\tif x == 'S':\n\t\t\trow -= 1\n\t\t\tbreak\nfor i in range(c):\n\tfor j in range(r):\n\t\tif a[j][i] == 'S':\n\t\t\tcol -= 1\n\t\t\tbreak\nprint(row * c + col * r - col * row)\n", "(r_val, c_val) = list(map(int, input().split()))\nrow_es = [0] * r_val\ncol_es = [0] * c_val\ndata = list()\neat_or_not = list()\nfor row in range(r_val):\n\tdata.append(input())\n\teat_or_not.append([0] * c_val)\nfor row in range(r_val):\n\tfor col in range(c_val):\n\t\tif data[row][col] == 'S':\n\t\t\trow_es[row] = 1\n\t\t\tcol_es[col] = 1\ncount = 0\nfor row in range(r_val):\n\tif row_es[row] == 0:\n\t\tfor col in range(c_val):\n\t\t\tif eat_or_not[row][col] == 0:\n\t\t\t\teat_or_not[row][col] = 1\n\t\t\t\tcount += 1\nfor col in range(c_val):\n\tif col_es[col] == 0:\n\t\tfor row in range(r_val):\n\t\t\tif eat_or_not[row][col] == 0:\n\t\t\t\teat_or_not[row][col] = 1\n\t\t\t\tcount += 1\nprint(count)\n", "(r, c) = (int(x) for x in input().split())\n(ck, rs, cs) = ([], set(), set())\nval = 0\n\ndef eat(i, j):\n\tglobal val\n\tif ck[i][j] == '.':\n\t\tck[i][j] = 'X'\n\t\tval += 1\nfor i in range(r):\n\tck.append(list(input()))\n\tfor (j, ce) in enumerate(ck[i]):\n\t\tif ce == 'S':\n\t\t\trs.add(i)\n\t\t\tcs.add(j)\nfor i in range(r):\n\tif i not in rs:\n\t\tfor j in range(c):\n\t\t\teat(i, j)\nfor j in range(c):\n\tif j not in cs:\n\t\tfor i in range(r):\n\t\t\teat(i, j)\nprint(val)\n", "line = [int(i) for i in str(input()).split()]\nrows = line[0]\ncolmuns = []\nfor row in range(line[0]):\n\tl = str(input())\n\tif 'S' in l:\n\t\trows -= 1\n\t\tfor i in range(line[1]):\n\t\t\tif l[i] == 'S' and (not i in colmuns):\n\t\t\t\tcolmuns.append(i)\nprint(rows * line[1] + (line[1] - len(colmuns)) * line[0] - rows * (line[1] - len(colmuns)))\n", "(r, c) = map(int, input().split())\nr_set = set()\nc_set = set()\nfor i in range(r):\n\ts = input()\n\tfor j in range(c):\n\t\tif s[j] == 'S':\n\t\t\tr_set.add(i)\n\t\t\tc_set.add(j)\nprint((r - len(r_set)) * c + (c - len(c_set)) * len(r_set))\n", "(r, c) = map(int, input().split())\nlist1 = []\nlist2 = []\nfor i in range(r):\n\tk = list(map(str, input().split()))\n\tlist1.append(k)\nfor i in range(len(list1)):\n\tlist2.append([])\n\tfor j in list1[i]:\n\t\tfor k in range(len(j)):\n\t\t\tlist2[i].append(j[k])\nlist1 = list2\ncount = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\tif list1[i][j] == '.' and list1[i][j] != 0:\n\t\t\ttemp = 0\n\t\t\tfor k in range(r):\n\t\t\t\tif list1[k][j] == 'S':\n\t\t\t\t\ttemp = 0\n\t\t\t\t\tbreak\n\t\t\t\telse:\n\t\t\t\t\tcount += 1\n\t\t\t\t\ttemp = 1\n\t\t\tif temp == 0:\n\t\t\t\tcount = 0\n\t\t\tif temp == 1:\n\t\t\t\tfor k in range(r):\n\t\t\t\t\tlist1[k][j] = 0\ncount1 = 0\nfor i in range(c):\n\tfor j in range(r):\n\t\tif list1[j][i] == '.' and list1[j][i] != 0:\n\t\t\ttemp = 0\n\t\t\tfor k in range(c):\n\t\t\t\tif list1[j][k] == 'S':\n\t\t\t\t\ttemp = 0\n\t\t\t\t\tbreak\n\t\t\t\telse:\n\t\t\t\t\tcount1 += 1\n\t\t\t\t\ttemp = 1\n\t\t\tif temp == 0:\n\t\t\t\tcount1 = 0\n\t\t\tif temp == 1:\n\t\t\t\tfor k in range(c):\n\t\t\t\t\tlist1[j][k] = 0\ncount = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\tif list1[i][j] == 0:\n\t\t\tcount += 1\nprint(count)\n", "n = [int(x) for x in input().split()]\nx = []\ny = []\nfor i in range(0, n[0]):\n\tt = input()\n\tfor j in range(0, n[1]):\n\t\tif t[j] == 'S':\n\t\t\tif i in x:\n\t\t\t\ti = i\n\t\t\telse:\n\t\t\t\tx.append(i)\n\t\t\tif j in y:\n\t\t\t\tj = j\n\t\t\telse:\n\t\t\t\ty.append(j)\nprint(n[0] * n[1] - len(x) * len(y))\n", "(r, c) = input().split()\nr = int(r)\nc = int(c)\nclist = [0] * c\ncount = 0\nkashi = c\nrash = r\nfor i in range(r):\n\tllist = list(map(str, input()))\n\tflag = 1\n\tfor j in range(c):\n\t\tif llist[j] == 'S':\n\t\t\tflag = 0\n\t\t\tclist[j] = 1\n\tif flag == 1:\n\t\tcount += kashi\n\t\trash -= 1\nfor item in clist:\n\tif item == 0:\n\t\tcount += rash\nprint(count)\n", "(x, y) = map(int, input().split())\np = []\nk = []\nnum = x * y\nfor i in range(x):\n\tf = input()\n\tif 'S' in f:\n\t\tfor j in range(len(f)):\n\t\t\tif f[j] == 'S':\n\t\t\t\tp.append(i)\n\t\t\t\tk.append(j)\nfor i in range(x):\n\tfor j in range(y):\n\t\tif i in p and j in k:\n\t\t\tnum -= 1\nprint(num)\n", "(r, c) = map(int, input().split())\ny = []\nt = 0\nfor i in range(r):\n\tk = input()\n\tl = list(k)\n\tu = 0\n\tfor j in range(len(l)):\n\t\tif l[j] == 'S':\n\t\t\ty.append(j)\n\t\t\tu = 1\n\tif u == 0:\n\t\tt = t + 1\ny = set(y)\ny = c - len(y)\nprint(y * r + (c - y) * t)\n", "integer = int\nstring = str\nlength = len\n\ndef main():\n\t(r, c) = list(map(integer, input().split()))\n\tm = []\n\trow = 0\n\tcolumn = 0\n\tfor _ in range(r):\n\t\ttemp = input()\n\t\tm.append(list(temp))\n\t\tif 'S' not in temp:\n\t\t\trow += 1\n\tm_t = list(zip(*m))\n\tfor i in range(c):\n\t\tif 'S' not in m_t[i]:\n\t\t\tcolumn += 1\n\tprint(row * c + column * r - column * row)\nmain()\n", "def Cakeminator():\n\t(rows, cols) = map(int, input().split())\n\tmax_eat = 0\n\trows_eat = 0\n\tgrid = []\n\tfor i in range(rows):\n\t\trow = input()\n\t\tif 'S' not in row:\n\t\t\trows_eat += 1\n\t\t\tmax_eat += cols\n\t\tgrid.append(row)\n\tfor i in range(cols):\n\t\tfound = False\n\t\tfor j in range(rows):\n\t\t\tif grid[j][i] == 'S':\n\t\t\t\tfound = True\n\t\t\t\tbreak\n\t\tif not found:\n\t\t\tmax_eat += rows - rows_eat\n\treturn max_eat\nremained_test_cases = 1\nwhile remained_test_cases > 0:\n\tprint(Cakeminator())\n\tremained_test_cases -= 1\n", "(r, c) = map(int, input().split())\n(rows, cols) = (set(), set())\nfor i in range(r):\n\ts = input()\n\tfor (j, v) in enumerate(s):\n\t\tif v == 'S':\n\t\t\trows.add(i)\n\t\t\tcols.add(j)\ncake = [[1] * c] * r\ncount = 0\nfor i in range(r):\n\tif i not in rows:\n\t\tcount += c\n\t\tcake[i] = [0] * c\nfor j in range(c):\n\tif j not in cols:\n\t\tcount += sum([cake[i][j] for i in range(r)])\nprint(count)\n", "(r, c) = map(int, input().split())\ntort = []\nfor i in range(r):\n\ttort.append(input())\nmas = [[False] * c for i in range(r)]\nfor i in range(r):\n\tif 'S' not in tort[i]:\n\t\tfor j in range(c):\n\t\t\tmas[i][j] = True\nfor j in range(c):\n\tis_find = False\n\tfor i in range(r):\n\t\tif tort[i][j] == 'S':\n\t\t\tis_find = True\n\t\t\tbreak\n\tif not is_find:\n\t\tfor i in range(r):\n\t\t\tmas[i][j] = True\ncount = 0\nfor row in mas:\n\tcount += row.count(True)\nprint(count)\n", "(n, m) = (int(x) for x in input().split())\nans = 0\na = []\nfor i in range(n):\n\ta.append(input())\n\tif 'S' not in a[i]:\n\t\tans += m\nans0 = ans\nfor i in range(m):\n\tk = 0\n\tfor j in range(n):\n\t\tif a[j][i] == 'S':\n\t\t\tk = 1\n\tif k == 0:\n\t\tans0 += n - ans // m\nprint(ans0)\n", "(r, c) = map(int, input().split())\na = [input() for i in range(r)]\nn = len([0 for s in a if 'S' not in s])\nm = len([0 for j in range(c) if len([s[j] for s in a if s[j] == '.']) == r])\nprint(n * c + m * r - n * m)\n", "(r, c) = map(int, input().split())\nh = [1] * c\nl = []\nfor i in range(r):\n\tl.append(input())\nm = []\nfor i in range(c):\n\tx = ''\n\tfor j in range(r):\n\t\tx += l[j][i]\n\tm.append(x)\n(cc, cr) = (0, 0)\nans = 0\nfor i in range(r):\n\tif l[i].find('S') == -1:\n\t\tans += c - cc\n\t\tcr += 1\n\telse:\n\t\tfor j in range(c):\n\t\t\tif l[i][j] == '.':\n\t\t\t\tif h[j] and m[j].find('S') == -1:\n\t\t\t\t\tans += r - cr\n\t\t\t\t\tcc += 1\n\t\t\t\t\th[j] = 0\nprint(ans)\n", "(r, c) = list(map(int, input().split()))\n(e, l) = ([], [])\ncount = 0\nfor i in range(r):\n\tl = list(input())\n\tif 'S' not in l:\n\t\tcount += 1\n\telse:\n\t\tfor j in range(c):\n\t\t\tif l[j] == 'S':\n\t\t\t\te.append(j)\ne = set(e)\nprint(count * c + ((c - len(e)) * r - (c - len(e)) * count))\n", "import itertools as ittls\nfrom collections import Counter\n\ndef inputarray(func=int):\n\treturn map(func, input().split())\n(n, m) = inputarray()\nrows = [0] * n\ncols = [0] * m\nfor i in range(n):\n\ts = input()\n\tfor (j, v) in enumerate(s):\n\t\tif v == 'S':\n\t\t\trows[i] = 1\n\t\t\tcols[j] = 1\nx1 = n - sum(rows)\nx2 = m - sum(cols)\nr1 = x1 * m\nr2 = x2 * n\nprint(r1 + r2 - x1 * x2)\n", "(n, m) = map(int, input().split())\na = []\nfor i in range(n):\n\ta.append(list(input()))\nb = []\nfor i in range(len(a)):\n\tif 'S' not in a[i]:\n\t\tfor j in range(m):\n\t\t\tb.append([i, j])\nfor i in range(m):\n\tflag = 0\n\tfor j in range(n):\n\t\tif a[j][i] == 'S':\n\t\t\tflag = 1\n\t\t\tbreak\n\tif flag != 1:\n\t\tfor j in range(n):\n\t\t\tb.append([j, i])\nc = []\nfor i in range(len(b)):\n\tif b[i] not in c:\n\t\tc.append(b[i])\nprint(len(c))\n", "(n, m) = map(int, input().split())\nc = []\nk = 0\nfor i in range(n):\n\tl = list(input())\n\tif 'S' not in l:\n\t\tk += m\n\t\tcontinue\n\tc.append(l)\na = len(c)\nfor i in range(m):\n\tfor j in range(a):\n\t\tif c[j][i] == 'S':\n\t\t\tbreak\n\telse:\n\t\tk += a\nprint(k)\n", "(r, c) = map(int, input().split())\ntort = []\nfor i in range(r):\n\ttort.append(input())\ncount = 0\nfor i in range(r):\n\tif 'S' not in tort[i]:\n\t\ttort[i] = tort[i].replace('.', '+')\n\t\tcount += c\nfor j in range(c):\n\tres = ''\n\tfor i in range(r):\n\t\tres += tort[i][j]\n\tif 'S' not in res:\n\t\tcount += res.count('.')\nprint(count)\n", "import sys\n\ndef main():\n\tcake = []\n\t(r, c) = list(map(int, sys.stdin.readline().split()))\n\tfor i in range(r):\n\t\tcake.append(sys.stdin.readline().strip())\n\trow_count = 0\n\tfor i in range(r):\n\t\tfound_strawberry = False\n\t\tfor j in range(c):\n\t\t\tif cake[i][j] == 'S':\n\t\t\t\tfound_strawberry = True\n\t\t\t\tbreak\n\t\tif found_strawberry is False:\n\t\t\trow_count += 1\n\tcol_count = 0\n\tfor j in range(c):\n\t\tfound_strawberry = False\n\t\tfor i in range(r):\n\t\t\tif cake[i][j] == 'S':\n\t\t\t\tfound_strawberry = True\n\t\t\t\tbreak\n\t\tif found_strawberry is False:\n\t\t\tcol_count += 1\n\tprint(row_count * c + col_count * r - row_count * col_count)\n\ndef __starting_point():\n\treturn main()\n__starting_point()\n", "(n, m) = map(int, input().split())\nx = n * [0]\ny = m * [0]\nfor i in range(n):\n\ts = input()\n\tfor j in range(m):\n\t\tif s[j] == 'S':\n\t\t\tx[i] = 1\n\t\t\ty[j] = 1\na = x.count(1)\nb = y.count(1)\nprint(n * m - a * b)\n", "import math\nimport collections\nimport bisect\nimport heapq\nimport time\nimport random\nimport itertools\nimport sys\n(N, M) = map(int, input().split())\nA = []\nfor i in range(N):\n\tA.append(list(input()))\nfor r in range(N):\n\tif all([A[r][c] != 'S' for c in range(M)]):\n\t\tfor c in range(M):\n\t\t\tA[r][c] = '1'\nfor c in range(M):\n\tif all([A[r][c] != 'S' for r in range(N)]):\n\t\tfor r in range(N):\n\t\t\tA[r][c] = '1'\nans = 0\nfor r in range(N):\n\tfor c in range(M):\n\t\tif A[r][c] == '1':\n\t\t\tans += 1\nprint(ans)\n", "(r, c) = map(int, input().split())\na = []\nb = []\nd = 0\nfor i in range(0, r):\n\ta = list(input())\n\tif 'S' not in a:\n\t\ta = [0] * c\n\t\td = d + c\n\tb.append(a)\nfor i in range(0, c):\n\tk = 0\n\tm = 0\n\tfor j in range(0, r):\n\t\tif b[j][i] == '.' or b[j][i] == 0:\n\t\t\tif b[j][i] == '.':\n\t\t\t\tm = m + 1\n\t\telse:\n\t\t\tk = 1\n\tif k == 0:\n\t\td = d + m\nprint(d)\n", "(n, m) = map(int, input().split())\nar = []\nfor i in range(n):\n\tt = list(input())\n\tfor j in range(m):\n\t\tif 'S' == t[j]:\n\t\t\tar.append((j, i))\nr = len(ar)\nfor i in range(r):\n\tfor j in range(i, r):\n\t\tif (ar[i][0], ar[j][1]) not in ar:\n\t\t\tar.append((ar[i][0], ar[j][1]))\n\t\tif (ar[j][0], ar[i][1]) not in ar:\n\t\t\tar.append((ar[j][0], ar[i][1]))\nprint(n * m - len(ar))\n", "(n, m) = map(int, input().split())\na = []\nl = 0\nfor j in range(n):\n\ts = input()\n\tif s.count('.') == m:\n\t\tl += m\n\t\ta.append('0' * m)\n\telse:\n\t\ta.append(s)\nfor i in range(m):\n\tk = 0\n\tfor j in range(n):\n\t\tif a[j][i] == 'S':\n\t\t\tbreak\n\t\telif a[j][i] == '.':\n\t\t\tk += 1\n\telse:\n\t\tl += k\nprint(l)\n", "(n, m) = map(int, input().split())\na = []\nfor i in range(n):\n\ta.append(input())\nfor i in range(n):\n\tF = True\n\tfor j in range(m):\n\t\tif a[i][j] == 'S':\n\t\t\tF = False\n\tif F:\n\t\tfor j in range(m):\n\t\t\ta[i] = a[i][:j] + '1' + a[i][j + 1:]\nfor i in range(m):\n\tF = True\n\tfor j in range(n):\n\t\tif a[j][i] == 'S':\n\t\t\tF = False\n\tif F:\n\t\tfor j in range(n):\n\t\t\ta[j] = a[j][:i] + '1' + a[j][i + 1:]\nans = 0\nfor i in range(n):\n\tfor j in range(m):\n\t\tif a[i][j] == '1':\n\t\t\tans += 1\nprint(ans)\n", "(r, c) = map(int, input().split())\na = []\nAnswer = 0\nCounter = 0\nfor i in range(r):\n\ta.append(input())\nfor i in range(r):\n\tif 'S' not in a[i]:\n\t\tAnswer += c\n\t\tCounter += 1\nfor i in range(c):\n\ts = ''\n\tfor j in range(r):\n\t\ts += a[j][i]\n\tif 'S' not in s:\n\t\tAnswer += r - Counter\nprint(Answer)\n", "(r, c) = list(map(int, input().split()))\ngrid = []\nscore = 0\nfor i in range(r):\n\tgrid.append(input())\nfor i in range(r):\n\tif 'S' not in grid[i]:\n\t\tscore += c\n\t\tgrid[i] = 'X' * c\nfor i in range(c):\n\tcolfound = False\n\tcolscore = 0\n\tfor j in range(r):\n\t\tif grid[j][i] == 'S':\n\t\t\tcolfound = True\n\t\telif grid[j][i] == '.':\n\t\t\tcolscore += 1\n\tif not colfound:\n\t\tscore += colscore\nprint(score)\n", "(d, n) = list(map(int, input().split()))\nc = l = k = 0\na = []\nfor i in range(d):\n\ts = input()\n\tif 'S' not in s:\n\t\tl += 1\n\t\tc += n\n\ta.append(s)\nm = []\nfor j in range(n):\n\tv = ''\n\tfor t in a:\n\t\tv = v + t[j]\n\tm.append(v)\nfor f in m:\n\tif 'S' not in f:\n\t\tk += 1\n\t\tc += d\nprint(c - k * l)\n", "(n, d) = map(int, input().split(' '))\nt1 = [0] * n\nt2 = [0] * d\nfor i in range(n):\n\tj = 0\n\tfor s in input():\n\t\tif s == 'S':\n\t\t\tt1[i] = 1\n\t\t\tt2[j] = 1\n\t\tj += 1\nres = 0\nfor i in range(n):\n\tfor j in range(d):\n\t\tif t1[i] != 1 or t2[j] != 1:\n\t\t\tres += 1\nprint(res)\n", "import sys, math, collections\nfrom collections import defaultdict\n\ndef file():\n\tsys.stdin = open('input.py', 'r')\n\tsys.stdout = open('output.py', 'w')\n\ndef get_array():\n\tl = list(map(int, input().split()))\n\treturn l\n\ndef get_2_ints():\n\t(a, b) = map(int, input().split())\n\treturn (a, b)\n\ndef get_3_ints():\n\t(a, b, c) = map(int, input().split())\n\treturn (a, b, c)\n\ndef sod(n):\n\t(n, c) = (str(n), 0)\n\tfor i in n:\n\t\tc += int(i)\n\treturn c\n\ndef getFloor(A, x):\n\t(left, right) = (0, len(A) - 1)\n\tfloor = -1\n\twhile left <= right:\n\t\tmid = (left + right) // 2\n\t\tif A[mid] == x:\n\t\t\treturn A[mid]\n\t\telif x < A[mid]:\n\t\t\tright = mid - 1\n\t\telse:\n\t\t\tfloor = A[mid]\n\t\t\tleft = mid + 1\n\treturn floor\n\ndef main():\n\t(r, c) = get_2_ints()\n\t(row, colm) = ([], [])\n\tfor i in range(r):\n\t\tl = input()\n\t\tfor j in range(c):\n\t\t\tif l[j] == 'S':\n\t\t\t\trow.append(i)\n\t\t\t\tcolm.append(j)\n\trow = list(set(row))\n\tcolm = list(set(colm))\n\tprint(r * c - len(row) * len(colm))\nmain()\n", "def answer():\n\ta = input().split()\n\ta = [int(x) for x in a]\n\ti = 0\n\tc = []\n\td1 = []\n\twhile i < a[0]:\n\t\td = list(input())\n\t\tj = 0\n\t\twhile j < len(d):\n\t\t\tif d[j] == 'S':\n\t\t\t\tif i not in c:\n\t\t\t\t\tc.append(i)\n\t\t\t\tif j not in d1:\n\t\t\t\t\td1.append(j)\n\t\t\tj += 1\n\t\ti += 1\n\tans = a[0] * a[1] - len(c) * len(d1)\n\tprint(ans)\nanswer()\n", "(r, c) = map(int, input().split())\n(sr, sc) = (0, set())\nfor i in range(r):\n\trw = input()\n\tif 'S' in rw:\n\t\tsr += 1\n\t\tfor (j, ch) in enumerate(rw):\n\t\t\tif ch == 'S':\n\t\t\t\tsc.add(j)\nprint(r * c - sr * len(sc))\n", "n = input()\n(r, c) = n.split()\nrows = []\ncount = 0\ncake = 0\nrocount = 0\nwhile count < int(r):\n\trow = input()\n\tif 'S' not in row:\n\t\tcake += int(c)\n\t\trocount += 1\n\trows.append(row)\n\tcount += 1\nfor x in range(0, int(c)):\n\tpre = ''\n\tfor y in rows:\n\t\tif y[x] == '.':\n\t\t\tpre += y[x]\n\t\telse:\n\t\t\tpre += y[x]\n\t\t\tbreak\n\tif 'S' not in pre:\n\t\tcake += int(r) - rocount\nprint(cake)\n", "(r, c) = map(int, input().split())\nl = [0] * r\nfor _ in range(r):\n\ta = input()\n\tl[_] = list(a)\nfor i in range(r):\n\tcount = 0\n\tfor j in range(c):\n\t\tif l[i][j] != 'S':\n\t\t\tcount += 1\n\tif count == c:\n\t\tfor k in range(c):\n\t\t\tl[i][k] = '1'\nfor col in range(c):\n\tcnt = 0\n\tfor row in range(r):\n\t\tif l[row][col] != 'S':\n\t\t\tcnt += 1\n\tif cnt == r:\n\t\tfor m in range(r):\n\t\t\tl[m][col] = '1'\ntotal = sum([l[a][b] == '1' for a in range(r) for b in range(c)])\nprint(total)\n", "(n, m) = map(int, input().split())\na = [1] * n\nb = [1] * m\nfor i in range(n):\n\tl = list(input())\n\twhile l.count('S') != 0:\n\t\tx = l.index('S')\n\t\tif x != -1:\n\t\t\ta[i] = 0\n\t\t\tb[x] = 0\n\t\t\tl[x] = '.'\nc1 = a.count(1)\nc2 = b.count(1)\nif c1 == 0 and c2 == 0:\n\tprint(0)\nelif c1 == 0:\n\tprint(c2 * n)\nelif c2 == 0:\n\tprint(c1 * m)\nelse:\n\tprint(c1 * m + (n - c1) * c2)\n", "(r, c) = [int(x) for x in input().split()]\ncake = []\nfor i in range(0, r):\n\trow = list(input())\n\tcake.append(row)\nrows = 0\ncols = 0\nfor i in range(0, r):\n\tfor j in range(0, c):\n\t\tif cake[i][j] == 'S':\n\t\t\tbreak\n\t\tif j == c - 1:\n\t\t\trows += 1\nfor j in range(0, c):\n\tfor i in range(0, r):\n\t\tif cake[i][j] == 'S':\n\t\t\tbreak\n\t\tif i == r - 1:\n\t\t\tcols += 1\nprint(rows * c + cols * r - rows * cols)\n", "(r, c) = map(int, input().split())\nl = []\ns = 0\nfor i in range(r):\n\tl.append(input().replace('.', '1'))\n\tif 'S' not in l[i]:\n\t\ts += c\n\t\tl[i] = '0' * c\nfor i in range(c):\n\ttr = True\n\tcount = 0\n\tfor j in range(r):\n\t\tif l[j][i] == 'S':\n\t\t\ttr = False\n\t\t\tbreak\n\t\telif l[j][i] == '1':\n\t\t\tcount += 1\n\tif tr:\n\t\ts += count\nprint(s)\n", "(rows, cols) = map(int, input().strip().split())\neats = 0\ncake = []\nfor _ in range(rows):\n\trow = input().strip()\n\tif 'S' not in row:\n\t\teats += cols\n\telse:\n\t\tcake.append(row)\nrows = len(cake)\nfor col in range(cols):\n\tfor row in cake:\n\t\tif row[col] == 'S':\n\t\t\tbreak\n\telse:\n\t\teats += rows\nprint(eats)\n", "(r, c) = map(int, input().split())\na = [input() for _ in [0] * r]\ns = lambda x: sum((i.count('S') > 0 for i in x))\nprint(r * c - s(a) * s(zip(*a)))\n", "def ContainsDoubleEvil(r, c, row, col, board):\n\tevil = 0\n\tif board[row].count('S') > 0:\n\t\tevil += 1\n\tif [ro[col] for ro in board].count('S') > 0:\n\t\tevil += 1\n\tif evil == 2:\n\t\treturn True\n\telse:\n\t\treturn False\n\ndef Cake():\n\t(r, c) = list(map(int, input().split()))\n\tboard = []\n\tfor i in range(r):\n\t\tboard.append(list(input()))\n\tcount = 0\n\tfor row in range(r):\n\t\tfor col in range(c):\n\t\t\tif board[row][col] == 'S':\n\t\t\t\tpass\n\t\t\telif ContainsDoubleEvil(r, c, row, col, board):\n\t\t\t\tpass\n\t\t\telse:\n\t\t\t\tcount += 1\n\tprint(count)\nCake()\n", "x = [int(item) for item in input().split()]\nrow = []\ncolumn = []\nanslist = []\nfor item in range(1, x[0] + 1):\n\ty = input()\n\ty = list(enumerate(y))\n\tfor (a, b) in y:\n\t\tif b == 'S':\n\t\t\trow.append(item)\n\t\t\tcolumn.append(a + 1)\nfor p in row:\n\tfor q in column:\n\t\tanslist.append((p, q))\nanslist = list(set(anslist))\nprint(x[0] * x[1] - len(anslist))\n", "import sys\n\ndef read():\n\treturn sys.stdin.readline()\na = []\n(r, c) = map(int, read().split())\nans = 0\nfor i in range(r):\n\ta.append(list(read()))\nfor i in range(r):\n\tok = False\n\tfor j in range(c):\n\t\tif a[i][j] == 'S':\n\t\t\tok = True\n\t\t\tbreak\n\tif ok == False:\n\t\tfor j in range(c):\n\t\t\ta[i][j] = '*'\n\t\t\tans += 1\nfor j in range(c):\n\tok = False\n\tfor i in range(r):\n\t\tif a[i][j] == 'S':\n\t\t\tok = True\n\t\t\tbreak\n\tif ok == False:\n\t\tfor i in range(r):\n\t\t\tif a[i][j] == '.':\n\t\t\t\tans += 1\nprint(ans)\n", "(r, c) = map(int, input().split())\na = [input() for i in range(r)]\nprint(r * c - len([1 for i in a if 'S' in i]) * len([1 for i in zip(*a) if 'S' in i]))\n", "import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools\nsys.setrecursionlimit(10 ** 7)\ninf = 10 ** 20\neps = 1.0 / 10 ** 10\nmod = 10 ** 9 + 7\ndd = [(-1, 0), (0, 1), (1, 0), (0, -1)]\nddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]\n\ndef LI():\n\treturn [int(x) for x in sys.stdin.readline().split()]\n\ndef LI_():\n\treturn [int(x) - 1 for x in sys.stdin.readline().split()]\n\ndef LF():\n\treturn [float(x) for x in sys.stdin.readline().split()]\n\ndef LS():\n\treturn sys.stdin.readline().split()\n\ndef I():\n\treturn int(sys.stdin.readline())\n\ndef F():\n\treturn float(sys.stdin.readline())\n\ndef S():\n\treturn input()\n\ndef pf(s):\n\treturn print(s, flush=True)\n\ndef main():\n\t(n, m) = LI()\n\ta = [S() for _ in range(n)]\n\tb = set()\n\tc = set()\n\tfor i in range(n):\n\t\tfor j in range(m):\n\t\t\tif a[i][j] == 'S':\n\t\t\t\tb.add(i)\n\t\t\t\tc.add(j)\n\tr = 0\n\tfor i in range(n):\n\t\tfor j in range(m):\n\t\t\tif i not in b or j not in c:\n\t\t\t\tr += 1\n\treturn r\nprint(main())\n", "(n, m) = map(int, input().split())\na = []\nc = []\nk = 0\nfor i in range(n):\n\tb = list(input())\n\tif not 'S' in b:\n\t\tk += m\n\t\tfor i in range(len(b)):\n\t\t\tb[i] = 'P'\n\t\ta.append(b)\n\telse:\n\t\ta.append(b)\nb = []\nfor i in range(m):\n\tfor j in range(n):\n\t\tb.append(a[j][i])\n\tif not 'S' in b:\n\t\tfor i in range(len(b)):\n\t\t\tif b[i] != 'P':\n\t\t\t\tk += 1\n\tb = []\nprint(k)\n", "(r, c) = [int(s) for s in input().split()]\na = []\ncounter = 0\nfor i in range(r):\n\ta.append([])\n\tfor b in str(input()):\n\t\ta[i].append(b)\nfor i in range(r):\n\tif a[i].count('S') > 0:\n\t\tcontinue\n\telse:\n\t\tfor j in range(c):\n\t\t\tif a[i][j] == '.':\n\t\t\t\ta[i][j] = '#'\n\t\t\t\tcounter += 1\nfor i in range(c):\n\tflag = True\n\tfor j in range(r):\n\t\tif a[j][i] == 'S':\n\t\t\tflag = False\n\t\t\tbreak\n\tif flag == True:\n\t\tfor j in range(r):\n\t\t\tif a[j][i] == '.':\n\t\t\t\ta[j][i] = '#'\n\t\t\t\tcounter += 1\nprint(counter)\n", "import sys\n\ndef data():\n\treturn sys.stdin.readline().strip()\n\ndef sp():\n\treturn map(int, data().split())\n\ndef l():\n\treturn list(sp())\ntemp = l()\nr = temp[0]\nc = temp[1]\nt = []\nnr = []\nnc = []\nfor i in range(r):\n\tt.append(list(data()))\nfor i in range(r):\n\tfor j in range(c):\n\t\tif t[i][j] == 'S':\n\t\t\tnr.append(i)\n\t\t\tnc.append(j)\ncommon = (r - len(set(nr))) * (c - len(set(nc)))\ntotal = (r - len(set(nr))) * c + (c - len(set(nc))) * r\neat = total - common\nif eat <= 0:\n\tprint(0)\nelse:\n\tprint(eat)\n", "(r, c) = map(int, input().split())\nL = []\nfor i in range(r):\n\tL.append(input())\n(n, m) = (0, 0)\nfor i in range(r):\n\tfor j in range(c):\n\t\tif L[i][j] == 'S':\n\t\t\tn += 1\n\t\t\tbreak\nfor i in range(c):\n\tfor j in range(r):\n\t\tif L[j][i] == 'S':\n\t\t\tm += 1\n\t\t\tbreak\nprint(r * c - n * m)\n", "(n, m) = map(int, input().split())\ns = ''\na = set()\nb = set()\nfor i in range(n):\n\ts = input()\n\tfor j in range(m):\n\t\tif s[j] == 'S':\n\t\t\ta.add(i)\n\t\t\tb.add(j)\nprint(m * n - len(a) * len(b))\n", "x = input().split(' ')\nrow = int(x[0])\ncol = int(x[1])\narr = []\nfor i in range(row):\n\tarr.append(input())\ncount = 0\nindexes = []\nfor i in range(len(arr)):\n\tif 'S' not in arr[i]:\n\t\tcount += len(arr[i])\n\t\tindexes.append(i)\nfor i in range(col):\n\tnoS = False\n\tfor j in range(row):\n\t\tif arr[j][i] == 'S':\n\t\t\tnoS = True\n\t\t\tbreak\n\tif not noS:\n\t\tcount += row\n\t\tif len(indexes) > 0:\n\t\t\tcount -= len(indexes)\nprint(count)\n", "(n, m) = map(int, input().split())\nmatrix = []\nfor i in range(n):\n\tmatrix.append(input())\nrows = [i for i in range(n)]\ncols = [i for i in range(m)]\nfor i in range(n):\n\tfor j in range(m):\n\t\tif matrix[i][j] == 'S':\n\t\t\trows[i] = -1\n\t\t\tcols[j] = -1\np_r = list(filter(lambda x: x >= 0, rows))\np_c = list(filter(lambda x: x >= 0, cols))\nprint(len(p_c) * n + len(p_r) * m - len(p_r) * len(p_c))\n", "__copyright__ = ''\n__author__ = 'Son-Huy TRAN'\n__email__ = 'sonhuytran@gmail.com'\n__doc__ = 'http://codeforces.com/problemset/problem/330/A'\n__version__ = '1.0'\n(row, col) = map(int, input().split())\ninputs = [''] * row\nhasS = {'row': [0] * row, 'col': [0] * col}\nfor i in range(row):\n\tinputs[i] = input()\nfor i in range(row):\n\tfor j in range(col):\n\t\tif inputs[i][j] == 'S':\n\t\t\thasS['row'][i] = 1\n\t\t\thasS['col'][j] = 1\nrowcount = row - sum(hasS['row'])\ncolcount = col - sum(hasS['col'])\nresult = rowcount * col + colcount * row - rowcount * colcount\nprint(result)\n", "arr = [int(i) for i in filter(None, input().split(' '))]\nl = arr[1]\nh = arr[0]\narr = []\nlast = []\nc = []\nfor i in range(h):\n\tarr.append(list(input()))\nfor i in range(l * h):\n\tc.append(i)\nfor i in range(h):\n\tfor j in range(l):\n\t\tif arr[i][j] != 'S':\n\t\t\ta = i * l + j\n\t\t\tarr[i][j] = c[a]\nfor i in range(l):\n\tvr = []\n\tfor j in range(h):\n\t\tif arr[j][i] != 'S':\n\t\t\tvr.append(arr[j][i])\n\tif len(vr) == h:\n\t\tfor j in range(h):\n\t\t\tif vr[j] not in last:\n\t\t\t\tlast.append(vr[j])\nfor i in range(h):\n\tvr = []\n\tfor j in range(l):\n\t\tif arr[i][j] != 'S':\n\t\t\tvr.append(arr[i][j])\n\tif len(vr) == l:\n\t\tfor j in range(l):\n\t\t\tif vr[j] not in last:\n\t\t\t\tlast.append(vr[j])\nprint(len(last))\n", "lst = []\nw = []\nf = 0\na = 0\nv = 0\nz = list(map(int, input().split()))\nfor _ in range(z[0]):\n\tw = list(map(str, input()))\n\tlst.append(w)\nfor i in range(z[0]):\n\tif 'S' not in lst[i]:\n\t\ta += z[1]\nfor i in range(z[1]):\n\tfor j in lst:\n\t\tif 'S' not in j[i]:\n\t\t\tv += 1\n\tif v == z[0]:\n\t\tf += z[0]\n\tv = 0\nprint(a + f - f // z[0] * (a // z[1]))\n", "(a, b) = map(int, input().split())\n(m, n, s) = ([], 0, 0)\nfor x in range(a):\n\tc = list(input())\n\tif 'S' not in c:\n\t\ts += b\n\t\tn += 1\n\telse:\n\t\tfor y in range(b):\n\t\t\tif c[y] == 'S':\n\t\t\t\tm.append(y)\nfor x in range(b):\n\tif x not in m:\n\t\ts += a - n\nprint(s)\n", "(r, c) = map(int, input().split())\nCntS = 0\nRow = []\nCol = []\nfor i in range(r):\n\ts = input()\n\tfor j in range(c):\n\t\tif s[j] == 'S':\n\t\t\tRow.append(i)\n\t\t\tCol.append(j)\n\t\t\tCntS += 1\nRow = set(Row)\nCol = set(Col)\nprint(r * c - len(Row) * len(Col))\n", "(r, c) = map(int, input().split())\np1 = []\np3 = []\np4 = []\nfor i in range(r):\n\tp2 = list(input())\n\tfor j in range(c):\n\t\tif p2[j] != '.':\n\t\t\tp3.append(i)\n\t\t\tp4.append(j)\n\tp1.append(p2)\nprint(r * c - len(set(p3)) * len(set(p4)))\n", "(r, c) = map(int, input().split())\ngrid = []\nfor i in range(r):\n\ts = list(input())\n\tgrid.append(s)\nrow = set()\ncol = set()\nfor i in range(r):\n\tfor j in range(c):\n\t\tif grid[i][j] == 'S':\n\t\t\trow.add(i)\n\t\t\tcol.add(j)\ncnt = 0\nfor i in range(r):\n\tif i not in row:\n\t\tt = 0\n\t\tfor j in range(c):\n\t\t\tgrid[i][j] = '#'\n\t\t\tt += 1\n\t\tcnt += t\nfor i in range(c):\n\tif i not in col:\n\t\tt = 0\n\t\tfor j in range(r):\n\t\t\tif grid[j][i] == '.':\n\t\t\t\tgrid[j][i] = '#'\n\t\t\t\tt += 1\n\t\tcnt += t\nprint(cnt)\n", "(r, c) = map(int, input().split())\n(row, colm) = ([], [])\nfor i in range(r):\n\tl = input()\n\tfor j in range(c):\n\t\tif l[j] == 'S':\n\t\t\trow.append(i)\n\t\t\tcolm.append(j)\nrow = list(set(row))\ncolm = list(set(colm))\nprint(r * c - len(row) * len(colm))\n", "(r, c) = map(int, input().split())\nm = []\nfor i in range(r):\n\tm.append(list(input()))\ncells = 0\nfor i in range(len(m)):\n\tif m[i].count('S') == 0:\n\t\tcells += m[i].count('.')\n\t\tm[i] = ['E'] * len(m[i])\nfor i in range(len(m[0])):\n\tcolumn = []\n\tfor j in range(len(m)):\n\t\tcolumn.append(m[j][i])\n\tstranberry = column.count('S')\n\tif stranberry == 0:\n\t\tcells += column.count('.')\nprint(cells)\n", "(r, c) = map(int, input().split())\nrow = []\ncolumn = []\nfor i in range(r):\n\ttemp = input()\n\tfor j in range(c):\n\t\tif temp[j] == 'S':\n\t\t\trow.append(i)\n\t\t\tcolumn.append(j)\nrow = set(row)\ncolumn = set(column)\nprint(r * c - len(row) * len(column))\n", "for i in range(1):\n\t(r, c) = [int(x) for x in input().split()]\n\tl = []\n\tfor i in range(r):\n\t\tk = input()\n\t\tl.append(k)\n\trs = []\n\tcs = []\n\tans = 0\n\trows = 0\n\tcols = 0\n\tfor i in range(r):\n\t\tflag = 0\n\t\tfor j in range(c):\n\t\t\tif l[i][j] == 'S':\n\t\t\t\trs.append(i)\n\t\t\t\tcs.append(j)\n\t\t\t\tflag = 1\n\t\tif not flag:\n\t\t\trows += 1\n\tfor i in range(c):\n\t\tflag = 0\n\t\tfor j in range(r):\n\t\t\tif l[j][i] == 'S':\n\t\t\t\trs.append(i)\n\t\t\t\tcs.append(j)\n\t\t\t\tflag = 1\n\t\tif not flag:\n\t\t\tcols += 1\n\tans += rows * c + cols * r\n\tans -= rows * cols\n\tprint(ans)\n", "(n, m) = map(int, input().split())\nA = [0] * n\nfor k in range(n):\n\tA[k] = input()\nB = [0] * m\nfor k in range(m):\n\ts = ''\n\tfor j in range(n):\n\t\ts += A[j][k]\n\tB[k] = s\ncont = 0\ni = 0\nfor k in A:\n\tif not 'S' in k:\n\t\tcont += m\n\t\ti += 1\nfor k in B:\n\tif not 'S' in k:\n\t\tcont += n - i\nprint(cont)\n", "(a, b) = map(int, input().split())\n(c, d) = ([], [])\nfor i in range(a):\n\tc.append(input())\nfor i in range(b):\n\te = ''\n\tfor j in range(a):\n\t\te += c[j][i]\n\td.append(e)\neats = 0\nfor i in range(a):\n\tfor j in range(b):\n\t\tif 'S' not in c[i] or 'S' not in d[j]:\n\t\t\teats += 1\nprint(eats)\n", "(n, m) = map(int, input().split())\ng = [input() for i in range(n)]\nprint(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)])))]))\n", "(r, c) = map(int, input().split())\ncake_row = []\nfor i in range(r):\n\tcake_row.append(input())\nfree_row = 0\nfor i in range(r):\n\tif 'S' not in cake_row[i]:\n\t\tfree_row += 1\nfree_col = 0\nfor j in range(c):\n\tcake_col = ''.join([s[j] for s in cake_row])\n\tif 'S' not in cake_col:\n\t\tfree_col += 1\nprint(free_col * (r - free_row) + free_row * c)\n", "(n, m) = map(int, input().split())\na = [list(input()) for _ in range(n)]\n(r, c) = (set(), set())\nfor i in range(n):\n\tok = True\n\tfor j in range(m):\n\t\tif a[i][j] == 'S':\n\t\t\tok = False\n\tif ok:\n\t\tr.add(i)\nfor j in range(m):\n\tok = True\n\tfor i in range(n):\n\t\tif a[i][j] == 'S':\n\t\t\tok = False\n\tif ok:\n\t\tc.add(j)\nans = 0\nfor i in range(n):\n\tif i in r:\n\t\tfor j in range(m):\n\t\t\tans += 1\n\t\t\ta[i][j] = 'S'\nfor j in range(m):\n\tif j in c:\n\t\tfor i in range(n):\n\t\t\tans += a[i][j] == '.'\nprint(ans)\n", "def transpose(mat, n, m):\n\tz = []\n\tfor i in range(m):\n\t\tk = []\n\t\tfor j in range(n):\n\t\t\tk.append(mat[j][i])\n\t\tz.append(k)\n\treturn z\n(n, m) = map(int, input().split())\nc = []\nfor i in range(n):\n\tl = list(input())\n\tc.append(l)\nk = transpose(c, n, m)\np = 0\nh = 0\nv = 0\nfor i in range(len(c)):\n\tif c[i] == ['.'] * m:\n\t\tp += m\n\t\th += 1\nfor i in range(len(k)):\n\tif k[i] == ['.'] * n:\n\t\tp += n\n\t\tv += 1\np -= h * v\nprint(p)\n", "(row, col) = map(int, input().split())\na = set()\nb = set()\nfor i in range(row):\n\ts = input()\n\tfor j in range(col):\n\t\tif s[j] == 'S':\n\t\t\ta.add(i)\n\t\t\tb.add(j)\nans = row * col - len(a) * len(b)\nprint(ans)\n", "(n, m) = map(int, input().split())\nM = [list(map(str, input())) for i in range(n)]\nk = 0\nfor i in range(n):\n\tc = 1\n\tfor j in range(m):\n\t\tif M[i][j] == 'S':\n\t\t\tc = 0\n\tif c == 1:\n\t\tfor j in range(m):\n\t\t\tif M[i][j] == '.':\n\t\t\t\tk = k + 1\n\t\t\t\tM[i][j] = '0'\nfor j in range(m):\n\tc = 1\n\tfor i in range(n):\n\t\tif M[i][j] == 'S':\n\t\t\tc = 0\n\tif c == 1:\n\t\tfor i in range(n):\n\t\t\tif M[i][j] != '0':\n\t\t\t\tk = k + 1\nprint(k)\n", "(r, c) = map(int, input().split())\nl = []\nfor i in range(r):\n\ttemp = input()\n\tl.append(temp)\nrr = set()\ncc = set()\nfor i in range(r):\n\tfor j in range(c):\n\t\tif l[i][j] == 'S':\n\t\t\trr.add(i)\n\t\t\tcc.add(j)\nres = r * c - len(rr) * len(cc)\nprint(res)\n", "x = input().split()\nr = int(x[0])\nc = int(x[1])\nl = []\nd = []\nfor i in range(r):\n\tl.append(input())\nfor j in range(r):\n\tif 'S' not in l[j]:\n\t\tfor k in range(c):\n\t\t\td.append(str(j) + str(k))\nfor a in range(c):\n\tw = 0\n\tfor b in range(r):\n\t\tif l[b][a] != 'S':\n\t\t\tw += 1\n\tif w == r:\n\t\tfor b in range(r):\n\t\t\td.append(str(b) + str(a))\nprint(len(list(set(d))))\n", "(x, y) = map(int, input().split())\nt = 0\na = [input() for i in range(x)]\nfor i in range(x):\n\tif a[i].count('S') == 0:\n\t\tt = t + y\nfor j in range(y):\n\tflag1 = 1\n\tr = 0\n\tfor k in range(x):\n\t\tif a[k].count('S') == 0:\n\t\t\tr = r + 1\n\t\tif a[k][j] == 'S':\n\t\t\tflag1 = 0\n\t\t\tbreak\n\tif k == x - 1 and flag1 == 1:\n\t\tt = t + x - r\nprint(t)\n", "def main(r, c, seq):\n\tanswer = 0\n\tfor i in range(r):\n\t\tk = seq[i].count(1)\n\t\tif k == 0:\n\t\t\tfor j in range(c):\n\t\t\t\titem = seq[i][j]\n\t\t\t\tif item == 0:\n\t\t\t\t\tseq[i][j] = 2\n\t\t\t\t\tanswer += 1\n\tfor i in range(c):\n\t\ttemp = 0\n\t\tfor j in range(r):\n\t\t\titem = seq[j][i]\n\t\t\tif item == 0:\n\t\t\t\ttemp += 1\n\t\t\telif item == 1:\n\t\t\t\ttemp = 0\n\t\t\t\tbreak\n\t\tanswer += temp\n\treturn answer\n\ndef init():\n\t(r, c) = list(map(int, input().split()))\n\tseq = []\n\tfor i in range(r):\n\t\ttemp = []\n\t\tfor item in input():\n\t\t\tif item == 'S':\n\t\t\t\ttemp += [1]\n\t\t\telse:\n\t\t\t\ttemp += [0]\n\t\tseq.append(temp)\n\tprint(main(r, c, seq))\ninit()\n", "s = input().split(' ')\nt = []\nz = []\nr = int(s[0])\nc = int(s[1])\ny = 0\nfor i in range(r):\n\ta = input()\n\tx = []\n\tfor k in range(c):\n\t\tx.append(a[k])\n\tt.append(x)\n\tz.append(x)\nfor j in range(r):\n\tif set(t[j]) == {'.'}:\n\t\tz.remove(t[j])\n\t\ty += c\nfor l in range(c):\n\tb = 0\n\tfor m in range(len(z)):\n\t\tif z[m][l] == '.':\n\t\t\tb += 1\n\tif b == len(z):\n\t\ty += len(z)\nprint(y)\n", "(n, p) = map(int, input().split())\narr = []\nfor i in range(n):\n\ts = str(input())\n\tarr.append(s)\ncount = 0\ncountExtra = 0\nfor i in range(n):\n\tcounts = 0\n\tk = 0\n\ttruth = True\n\twhile k < p and truth == True:\n\t\tif arr[i][k:k + 1] == '.':\n\t\t\tcounts += 1\n\t\tif arr[i][k:k + 1] == 'S':\n\t\t\ttruth = False\n\t\tk += 1\n\tif counts == p:\n\t\tcount += counts\n\t\tcountExtra += 1\nfor i in range(p):\n\tcountss = 0\n\tkk = 0\n\ttruthh = True\n\twhile kk < n and truthh == True:\n\t\tif arr[kk][i:i + 1] == '.':\n\t\t\tcountss += 1\n\t\tif arr[kk][i:i + 1] == 'S':\n\t\t\ttruthh = False\n\t\tkk += 1\n\tif countss == n:\n\t\tcount += countss\n\t\tcount -= countExtra\nprint(count)\n", "(a, b) = map(int, input().split())\ntort = []\nfor i in range(a):\n\ttort.append(input())\nmas = [[False] * b for i in range(a)]\nfor i in range(a):\n\tif 'S' not in tort[i]:\n\t\tfor j in range(b):\n\t\t\tmas[i][j] = True\nfor j in range(b):\n\tf = False\n\tfor i in range(a):\n\t\tif tort[i][j] == 'S':\n\t\t\tf = True\n\t\t\tbreak\n\tif not f:\n\t\tfor i in range(a):\n\t\t\tmas[i][j] = True\nR = 0\nfor i in range(a):\n\tfor j in range(b):\n\t\tif mas[i][j]:\n\t\t\tR += 1\nprint(R)\n", "t = input().split()\nr = int(t[0])\nc = int(t[1])\nslon = 0\nt = []\nfor i in range(r):\n\ttemp = input()\n\tif temp.count('S') == 0:\n\t\tslon += c\n\tt.append(temp)\nk = slon // c\nfor i in range(c):\n\ttemp = 0\n\tfor j in range(r):\n\t\tif t[j][i] == 'S':\n\t\t\ttemp += 1\n\tif temp == 0:\n\t\tslon += r - k\nprint(slon)\n", "gi = lambda : list(map(int, input().strip().split()))\n(n, m) = gi()\ncake = [input() for e in range(n)]\nl = len([1 for e in cake if 'S' not in e])\nc = len([1 for k in range(m) if 'S' not in [e[k] for e in cake]])\nprint(l * m + c * (n - l))\n", "(n, m) = map(int, input().split())\ns = []\nr = 0\nfor i in range(n):\n\ts.append(list(input()))\nfor i in s:\n\tif 'S' not in i:\n\t\tt = i.count('.')\n\t\tr += t\n\t\ts[s.index(i)] = [' '] * m\ns = list(zip(*s))\nfor i in s:\n\tif 'S' not in i:\n\t\tt = i.count('.')\n\t\tr += t\n\t\ts[s.index(i)] = [' '] * n\nprint(r)\n", "(r, c) = map(int, input().split())\nvals = []\nfor _ in range(r):\n\tvals.append(input())\nres = 0\nfor i in range(r):\n\tif 'S' not in vals[i]:\n\t\tres += vals[i].count('.')\n\t\tvals[i] = '*' * len(vals[i])\nfor i in range(c):\n\tcol = ''\n\tfor j in range(r):\n\t\tcol += vals[j][i]\n\tif 'S' not in col:\n\t\tres += col.count('.')\nprint(res)\n", "(r, c) = map(int, input().split())\ns = []\nd = [[], []]\nfor i in range(r):\n\ts.append(input())\nfor i in s:\n\tif i.count('.') == c:\n\t\td[0].append(c)\nfor i in range(c):\n\th = 0\n\tfor j in range(r):\n\t\tif s[j][i] == '.':\n\t\t\th += 1\n\tif h == r:\n\t\td[1].append(r)\na = sum(d[0]) + sum(d[1])\nb = len(d[0]) * len(d[1])\nprint(a - b)\n", "(a, b) = map(int, input().split())\nc = []\nd = []\nfor i in range(a):\n\tz = list(input())\n\tfor j in range(b):\n\t\tif z[j] == 'S':\n\t\t\tc.append(i)\n\t\t\td.append(j)\nprint(a * b - len(list(set(c))) * len(list(set(d))))\n", "(r, c) = map(int, input().split())\nmatrix = []\nnumber = 0\ncount1 = 0\ncount2 = 0\nfor i in range(r):\n\tx = input()\n\tmatrix.append(list(x[:c]))\nfor i in range(r):\n\tcount = 0\n\tfor j in range(c):\n\t\tif matrix[i][j] == 'S':\n\t\t\tbreak\n\telse:\n\t\tnumber += c\n\t\tcount1 += 1\nfor j in range(c):\n\tfor i in range(r):\n\t\tif matrix[i][j] == 'S':\n\t\t\tbreak\n\telse:\n\t\tnumber += r\n\t\tcount2 += 1\nprint(number - count1 * count2)\n", "(r, c) = map(int, input().split())\n(x, y) = ([], [])\nfor i in range(r):\n\ta = input()\n\tfor j in range(c):\n\t\tif a[j] == 'S':\n\t\t\tx.append(i)\n\t\t\ty.append(j)\nprint(r * c - len(set(x)) * len(set(y)))\n", "(n, m) = map(int, input().split())\nx = []\nfor i in range(n):\n\tx.append(list(input()))\nc = 0\nfor i in range(n):\n\ts = 0\n\tb = 0\n\tfor j in range(m):\n\t\tif x[i][j] == '.':\n\t\t\tb += 1\n\t\tif x[i][j] == 'S':\n\t\t\ts += 1\n\t\t\tbreak\n\tif s == 0:\n\t\tfor j in range(m):\n\t\t\tx[i][j] = '0'\n\t\tc += b\nfor i in range(m):\n\ts = 0\n\tb = 0\n\tfor j in range(n):\n\t\tif x[j][i] == '.':\n\t\t\tb += 1\n\t\tif x[j][i] == 'S':\n\t\t\ts += 1\n\t\t\tbreak\n\tif s == 0:\n\t\tc += b\nprint(c)\n", "(n, m) = map(int, input().split())\na = []\nfor i in range(n):\n\tb = list(input())\n\ta.append(b)\ns = 0\nz = 0\nfor i in range(n):\n\tif 'S' not in a[i]:\n\t\tz += 1\n\t\ts += len(a[i])\nfor i in range(m):\n\td = []\n\tfor j in range(n):\n\t\td.append(a[j][i])\n\tif 'S' not in d:\n\t\ts += len(d) - z\nprint(s)\n", "data = input()\ndata = data.split()\nr = int(data[0])\nc = int(data[1])\ncake = []\nfor i in range(r):\n\tcake.append(input())\n\ndef delete_rows(cake):\n\tmaxi = 0\n\tkeys = []\n\tfor (key, row) in enumerate(cake):\n\t\tif 'S' not in row:\n\t\t\tmaxi = maxi + len(row)\n\t\t\tkeys.append(key)\n\tcount = 0\n\tfor val in keys:\n\t\tcake.pop(val - count)\n\t\tcount += 1\n\treturn (cake, maxi)\n\ndef delete_columns(cake_columns):\n\tmaxi = 0\n\tkeys = []\n\tfor (key, column) in enumerate(cake_columns):\n\t\tif 'S' not in column:\n\t\t\tmaxi = maxi + len(column)\n\t\t\tkeys.append(key)\n\tcount = 0\n\tfor val in keys:\n\t\tcake_columns.pop(val - count)\n\t\tcount += 1\n\treturn (cake_columns, maxi)\n\ndef inverse(cake):\n\tcake_columns = []\n\tfor line in cake:\n\t\tif cake_columns == []:\n\t\t\tfor cell in line:\n\t\t\t\tcake_columns.append(cell)\n\t\telse:\n\t\t\tvalue = 1\n\t\t\tfor (key, column) in enumerate(cake_columns):\n\t\t\t\tcolumn = column + line[key:value]\n\t\t\t\tcake_columns[key] = column\n\t\t\t\tvalue += 1\n\treturn cake_columns\n\ndef is_posible(cake, maxi1, maxi2):\n\tmaxi = maxi1 + maxi2\n\tposible = False\n\tvalues = [0 for _ in range(len(cake[0]))]\n\tfor row in cake:\n\t\tfor (key, cell) in enumerate(row):\n\t\t\tif cell == '.':\n\t\t\t\tvalues[key] += 1\n\tfor val in values:\n\t\tif val == len(cake[0]):\n\t\t\tposible = True\n\treturn (maxi, posible)\nmaxi = 0\n(cake, maxi1) = delete_rows(cake)\ncake_columns = inverse(cake)\n(cake, maxi2) = delete_columns(cake_columns)\nmaxif = maxi1 + maxi2\nprint(maxif)\n", "line = input()\nline = line.split()\nrows = int(line[0])\ncols = int(line[1])\nrow = [0] * rows\ncol = [0] * cols\nn = 0\nm = cols\ntotal = 0\nfor i in range(0, rows):\n\tline = input()\n\tchara = list(line)\n\tfor j in range(0, cols):\n\t\tif chara[j] == 'S':\n\t\t\trow[i] = 1\n\t\t\tif col[j] != 1:\n\t\t\t\tm = m - 1\n\t\t\t\tcol[j] = 1\n\tif row[i] == 0:\n\t\tn = n + 1\ntotal = n * cols\ntotal = total + m * (rows - n)\nprint(total)\n", "(n, m) = map(int, input().split())\nM = []\nm1 = [['.' for j in range(m)] for i in range(n)]\nfor i in range(n):\n\ts = input()\n\tM.append(s)\nans = 0\nfor i in range(n):\n\tevil = False\n\tfor j in range(m):\n\t\tif M[i][j] == 'S':\n\t\t\tevil = True\n\t\t\tbreak\n\tif not evil:\n\t\tfor k in range(m):\n\t\t\tm1[i][k] = '1'\nfor i in range(m):\n\tevil = False\n\tfor j in range(n):\n\t\tif M[j][i] == 'S':\n\t\t\tevil = True\n\t\t\tbreak\n\tif not evil:\n\t\tfor k in range(n):\n\t\t\tm1[k][i] = '1'\nfor i in range(n):\n\tfor j in range(m):\n\t\tif m1[i][j] == '1':\n\t\t\tans += 1\nprint(ans)\n", "(r, c) = [int(x) for x in input().split()]\ncake = []\nnum = 0\nfor i in range(r):\n\trow = input()\n\tif '.' in row and 'S' not in row:\n\t\tcake.append('0' * c)\n\t\tnum = num + c\n\telse:\n\t\tcake.append(row)\nfor j in range(c):\n\tcolumn = [cake[i][j] for i in range(r)]\n\tif '.' in column and 'S' not in column:\n\t\tcolumn_ = ''.join(column)\n\t\tnum = num + column_.count('.')\nprint(num)\n", "(r, c) = map(int, input().split())\na = []\ns = 0\nfor i in range(r):\n\ta.append(input())\n\tif 'S' not in a[i]:\n\t\ts += a[i].count('.')\n\t\ta[i] = '-' * c\nfor j in range(c):\n\tstr = ''\n\tfor i in range(r):\n\t\tstr += a[i][j]\n\tif 'S' not in str:\n\t\ts += str.count('.')\nprint(s)\n", "(r, c) = map(int, input().split())\n(A, B) = ([], [])\nfor i in range(r):\n\tR = list(input())\n\twhile 'S' in R:\n\t\tI = R.index('S')\n\t\tB += [I]\n\t\tA += [i]\n\t\tR[I] = '.'\nprint(r * c - len(set(A)) * len(set(B)))\n", "(r, c) = [int(string) for string in input().split()]\nrows = []\nfor row in range(0, r):\n\trows.append(list(input()))\nclear_rows_count = 0\nclear_cols_count = 0\nfor row in range(0, r):\n\tif rows[row].count('.') == c:\n\t\tclear_rows_count += 1\nfor col in range(0, c):\n\tdot_count = 0\n\tfor row in range(0, r):\n\t\tif rows[row][col] == '.':\n\t\t\tdot_count += 1\n\tif dot_count == r:\n\t\tclear_cols_count += 1\nprint(clear_rows_count * c + clear_cols_count * r - clear_rows_count * clear_cols_count)\n", "(row, column) = [int(x) for x in input().split()]\nrowset = set([])\ncolumnset = set([])\nrowdone = 0\ncolumndone = 0\nfor i in range(row):\n\tli = list(input())\n\tfor (j, w) in enumerate(li):\n\t\tif w == 'S':\n\t\t\trowset.add(i)\n\t\t\tcolumnset.add(j)\nans = 0\nfor i in range(row):\n\tif i not in rowset:\n\t\tans += column - columndone\n\t\trowdone += 1\nfor i in range(column):\n\tif i not in columnset:\n\t\tans += row - rowdone\n\t\tcolumndone += 1\nprint(ans)\n", "def string_to_list(a):\n\ty = []\n\tfor i in range(len(a)):\n\t\ty.append(a[i])\n\treturn y\na = list(map(int, input().split()))\n(r, c, b) = (a[0], a[1], [])\nfor i in range(r):\n\td = input()\n\td1 = string_to_list(d)\n\tb.append(d1)\nfor i in range(c):\n\tes = 0\n\tfor j in range(r):\n\t\tif b[j][i] == 'S':\n\t\t\tes += 1\n\t\t\tbreak\n\tif es == 0:\n\t\tfor k in range(r):\n\t\t\tb[k][i] = 'E'\nfor i in range(r):\n\tes1 = 0\n\tfor j in range(c):\n\t\tif b[i][j] == 'S':\n\t\t\tes1 += 1\n\t\t\tbreak\n\tif es1 == 0:\n\t\tfor k in range(c):\n\t\t\tb[i][k] = 'E'\ncount = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\tif b[i][j] == 'E':\n\t\t\tcount += 1\nprint(count)\n", "(r, c) = map(int, input().split())\nlst = [[s for s in input()] for _ in range(r)]\ncount = 0\ncol = []\nfor i in range(r):\n\tif 'S' not in lst[i]:\n\t\tcount += 1\n\tfor j in range(c):\n\t\tif lst[i][j] == 'S' and j not in col:\n\t\t\tcol.append(j)\nprint((c - len(col)) * (r - count) + count * c)\n", "(r, c) = [int(x) for x in input().split()]\nlst = []\nfor _ in range(r):\n\ts = input()\n\tlst.append(list(s))\n(eat, e) = (0, 0)\nfor i in lst:\n\tif 'S' not in i:\n\t\teat += c\n\t\te += 1\nfor i in range(c):\n\tno = 0\n\tfor j in range(r):\n\t\tif lst[j][i] == 'S':\n\t\t\tno += 1\n\t\t\tbreak\n\tif no == 0:\n\t\teat += r - e\nprint(eat)\n", "(b, a) = map(int, input().split())\ni = 0\nj = 0\no = 0\nbo = True\ns = []\nst = ''\nt = [[0 for i in range(a)] for j in range(b)]\nfor i in range(0, b):\n\tfor j in range(0, a):\n\t\tt[i][j] = 1\nfor i in range(0, b):\n\tst = str(input())\n\ts.append(st)\nfor i in range(0, b):\n\tfor j in range(0, a):\n\t\tbo = True\n\t\tfor k in range(0, a):\n\t\t\tif s[i][k] == 'S':\n\t\t\t\tbo = False\n\t\tif bo == True:\n\t\t\tfor k in range(0, a):\n\t\t\t\tif t[i][k] != 0:\n\t\t\t\t\tt[i][k] = 0\n\t\t\t\t\to += 1\n\t\tbo = True\n\t\tfor k in range(0, b):\n\t\t\tif s[k][j] == 'S':\n\t\t\t\tbo = False\n\t\tif bo == True:\n\t\t\tfor k in range(0, b):\n\t\t\t\tif t[k][j] != 0:\n\t\t\t\t\tt[k][j] = 0\n\t\t\t\t\to += 1\n\t\tif i != 0:\n\t\t\tbreak\nprint(o)\n", "(r, c) = list(map(int, input().split()))\nstr = []\nfor i in range(0, r):\n\taLine = input()\n\tstr.append(aLine)\nres = 0\nfor i in range(0, r):\n\tk = 1\n\tfor j in range(0, c):\n\t\tif str[i][j] == 'S':\n\t\t\tk = 0\n\t\t\tbreak\n\tif k == 1:\n\t\tres = res + c\n\t\tstr[i] = ''\n\t\tfor j in range(0, c):\n\t\t\tstr[i] = str[i] + '0'\nfor j in range(0, c):\n\tk = 1\n\tfor i in range(0, r):\n\t\tif str[i][j] == 'S':\n\t\t\tk = 0\n\t\t\tbreak\n\tif k == 1:\n\t\tfor i in range(0, r):\n\t\t\tif str[i][j] == '.':\n\t\t\t\tres = res + 1\nprint(res)\n", "(r, c) = list(map(int, input().split()))\nl = [0] * c\nh = [0] * r\na = []\nfor i in range(r):\n\ta.append([])\n\tls = list(input())\n\tfor j in range(c):\n\t\ta[i].append(ls[j])\n\t\tif a[i][j] != '.':\n\t\t\tl[j] = 1\n\t\t\th[i] = 1\n\t\telse:\n\t\t\ta[i][j] = 1\nt = 0\nfor i in range(r):\n\tif h[i] == 0:\n\t\tfor j in range(c):\n\t\t\tt += a[i][j]\n\t\t\ta[i][j] = 0\nfor i in range(c):\n\tif l[i] == 0:\n\t\tfor j in range(r):\n\t\t\tt += a[j][i]\n\t\t\ta[j][i] = 0\nprint(t)\n", "(r, c) = map(int, input().split())\nf = lambda x: 1 if x == '.' else 0\neat = 0\nl = []\nintersection = 0\nfor i in range(r):\n\to = input()\n\tif o.find('S') != -1:\n\t\tl.append(list(map(f, list(o))))\n\telse:\n\t\teat += c\n\t\tintersection += 1\nl = zip(*l)\nfor k in list(l):\n\tif 0 not in k:\n\t\teat += r - 1 * intersection\nprint(eat)\n", "(n, m) = map(int, input().split())\na = [str(input()) for i in range(n)]\nb = [0 for i in range(n)]\nc = [0 for i in range(m)]\nfor i in range(n):\n\tfor j in range(m):\n\t\tif a[i][j] == 'S':\n\t\t\tb[i] = 1\n\t\t\tc[j] = 1\nprint(n * m - sum(b) * sum(c))\n", "(r, c) = map(int, input().split())\nmatrix = []\nfor _ in range(r):\n\tmatrix.append(input())\n(row, col) = (0, 0)\nfor i in range(r):\n\tif matrix[i].find('S') != -1:\n\t\trow += 1\nfor j in range(c):\n\tfor i in range(r):\n\t\tif matrix[i][j] == 'S':\n\t\t\tcol += 1\n\t\t\tbreak\nprint(r * c - row * col)\n", "firstLine = [int(x) for x in input().split()]\nheight = firstLine[0]\nwidth = firstLine[1]\ntotal = 0\ngame = []\nfor i in range(0, height):\n\tgame.append(str(input()))\n\ttemp = width\n\ttempString = ''\n\treplace = True\n\tfor j in range(0, len(game[-1])):\n\t\tif game[-1][j] == 'S':\n\t\t\ttempString += 'S'\n\t\t\ttemp = 0\n\t\t\treplace = False\n\t\telse:\n\t\t\ttempString += 'X'\n\tif replace:\n\t\tgame[-1] = tempString\n\ttotal += temp\nfor i in range(0, width):\n\ttemp = 0\n\tfor j in range(0, height):\n\t\tif game[j][i] == '.':\n\t\t\ttemp += 1\n\t\telif game[j][i] == 'S':\n\t\t\ttemp = 0\n\t\t\tbreak\n\ttotal += temp\nprint(total)\n", "(r, c) = map(int, input().split())\nli = []\ncount = 0\nfor i in range(r):\n\ts = list(input())\n\tif 'S' not in s:\n\t\tcount += c\n\t\ts = ['*'] * c\n\tli.append(s)\nresult = [[li[j][i] for j in range(len(li))] for i in range(len(li[0]))]\nfor i in range(c):\n\ts = result[i][0:r]\n\tif 'S' not in s:\n\t\tcount += s.count('.')\nprint(count)\n", "def cake(s):\n\tans = 0\n\tfor (i, n) in enumerate(s):\n\t\tif 'S' in n:\n\t\t\tcontinue\n\t\telse:\n\t\t\ts[i] = ['E'] * len(n)\n\t\t\tans += len(n)\n\tx = list(zip(*s))\n\tfor (i, n) in enumerate(x):\n\t\tif 'S' in n:\n\t\t\tcontinue\n\t\telse:\n\t\t\tans += n.count('.')\n\treturn ans\n(r, c) = list(map(int, input().rstrip().split()))\ns = []\nfor i in range(r):\n\tx = list(input())\n\ts.append(x)\nprint(cake(s))\n", "(a, b) = map(int, input().split())\nr = 0\nk = [0] * b\nfor _ in ' ' * a:\n\tg = input()\n\tif 'S' not in g:\n\t\tr += b\n\telse:\n\t\tfor i in range(b):\n\t\t\tif g[i] == 'S':\n\t\t\t\tk[i] = k[i] + 1\nprint(r + k.count(0) * a - r // b * k.count(0))\n", "(a, b) = [int(i) for i in input().split()]\nk = []\nl = []\nst = 0\nts = 0\ntrt = 0\nfor i in range(a):\n\tk.append(input())\n\tif 'S' not in k[i]:\n\t\tst += 1\n\t\ttrt += b\nfor j in range(b):\n\tfor f in range(a):\n\t\tif k[f][j] == 'S':\n\t\t\tbreak\n\telse:\n\t\tts += 1\n\t\ttrt += a\nmn = st * ts\nprint(trt - mn)\n", "(r, c) = list(map(int, input().split()))\nL = []\nfor i in range(r):\n\ts = input()\n\tL.append(str(s))\nans = r * c\nfor i in range(r):\n\tfor j in range(c):\n\t\tif L[i][j] == 'S':\n\t\t\tans -= 1\n\t\t\tcontinue\n\t\tif 'S' in L[i]:\n\t\t\tcase = False\n\t\t\tfor z in range(r):\n\t\t\t\tif L[z][j] == 'S':\n\t\t\t\t\tcase = True\n\t\t\t\t\tbreak\n\t\t\tif case:\n\t\t\t\tans -= 1\nprint(ans)\n", "X = list(map(int, input().split()))\nRows = list()\nfor i in range(X[0]):\n\tRows.append(input())\nColumns = list()\nfor i in range(X[1]):\n\tTempStr = str()\n\tfor j in range(X[0]):\n\t\tTempStr += Rows[j][i]\n\tColumns.append(TempStr)\nintRow = 0\nintColumn = 0\nfor i in Rows:\n\tif 'S' not in i:\n\t\tintRow += 1\nfor i in Columns:\n\tif 'S' not in i:\n\t\tintColumn += 1\nprint(str(intRow * X[1] + intColumn * (X[0] - intRow)))\n", "(r, c) = map(int, input().split())\nw = []\nfor i in range(r):\n\tl = input()\n\tw.append(l)\nrt = []\ntu = 0\nrow = []\nfor i in range(r):\n\tcou = 0\n\tfor j in range(c):\n\t\tcou += 1\n\t\tif w[i][j] == 'S':\n\t\t\tcou = 0\n\t\t\tbreak\n\tif cou > 0:\n\t\trow.append(i)\n\ttu += cou\nfor i in range(c):\n\tcou = 0\n\tfor j in range(r):\n\t\tif j in row:\n\t\t\trytu = 0\n\t\telse:\n\t\t\tcou += 1\n\t\t\tif w[j][i] == 'S':\n\t\t\t\tcou = 0\n\t\t\t\tbreak\n\ttu += cou\nprint(tu)\n", "rows = [0] * 10\ncols = [0] * 10\narr = input().split()\nm = int(arr[0])\nn = int(arr[1])\nfor i in range(m):\n\tarr = list(input())\n\tfor j in range(n):\n\t\tif arr[j] == 'S':\n\t\t\trows[i] = cols[j] = 1\nr = n\nc = m\nans = 0\nfor i in range(m):\n\tif rows[i] == 0:\n\t\tans += r\n\t\tc -= 1\nfor i in range(n):\n\tif cols[i] == 0:\n\t\tans += c\nprint(int(ans))\n", "(n, m) = map(int, input().split())\nrow = set()\ncol = set()\nans = 0\nfor i in range(n):\n\ts = input()\n\tfor j in range(m):\n\t\tif s[j] == 'S':\n\t\t\trow.add(i)\n\t\t\tcol.add(j)\nans = n * m\nx = len(row) * len(col)\nprint(ans - x)\n", "from sys import stdin, stdout\nimport re\n\ndef solve():\n\t(r, c) = map(int, stdin.readline().split())\n\tsr = [1 for i in range(r)]\n\tsc = [1 for j in range(c)]\n\tfor i in range(r):\n\t\tline = stdin.readline().strip()\n\t\tfor j in range(c):\n\t\t\tif line[j] == 'S':\n\t\t\t\tsr[i] = 0\n\t\t\t\tsc[j] = 0\n\tans = 0\n\tcake = [[0 for i in range(c)] for j in range(r)]\n\tfor i in range(r):\n\t\tif sr[i] == 0:\n\t\t\tcontinue\n\t\tfor j in range(c):\n\t\t\tif cake[i][j] == 0:\n\t\t\t\tcake[i][j] = 1\n\t\t\t\tans += 1\n\tfor j in range(c):\n\t\tif sc[j] == 0:\n\t\t\tcontinue\n\t\tfor i in range(r):\n\t\t\tif cake[i][j] == 0:\n\t\t\t\tcake[i][j] = 1\n\t\t\t\tans += 1\n\tprint(ans)\nLOCAL_TEST = not __debug__\nif LOCAL_TEST:\n\tinfile = __file__.split('.')[0] + '-test.in'\n\tstdin = open(infile, 'r')\ntcs = int(stdin.readline().strip()) if LOCAL_TEST else 1\nt = 1\nwhile t <= tcs:\n\tsolve()\n\tt += 1\n", "(n, m) = map(int, input().split())\nr = []\nc = []\nfor i in range(n):\n\tx = input()\n\tfor j in range(m):\n\t\tif x[j] == 'S':\n\t\t\tr.append(i)\n\t\t\tc.append(j)\nr = len(list(set(r)))\nc = len(list(set(c)))\nprint(n * m - r * c)\n", "(r, c) = input().split()\nr = int(r)\nc = int(c)\nrows = []\nevils = 0\nfor i in range(r):\n\trows.append(input())\n\tevils += rows[-1].count('S')\neaten = r * c - evils\ncolumns = []\nfor i in range(c):\n\tL = []\n\tfor j in range(r):\n\t\tL.append(rows[j][i])\n\tcolumns.append(L)\nfor i in range(r):\n\tfor j in range(c):\n\t\tif rows[i][j] == 'S':\n\t\t\tcontinue\n\t\telif 'S' in rows[i] and 'S' in columns[j]:\n\t\t\teaten -= 1\nprint(eaten)\n", "(x, y) = input().split()\n(a, b) = (int(x), int(y))\n(row, coloum) = (0, 0)\nlist = []\nfor i in range(a):\n\tlist.append(input())\nfor i in range(a):\n\tif 'S' not in list[i]:\n\t\trow = row + 1\nfor i in range(b):\n\tif 'S' not in [row[i] for row in list]:\n\t\tcoloum = coloum + 1\nprint(row * b + coloum * a - row * coloum)\n", "(r, c) = map(int, input().split())\n(arr, flag, ans) = ([], 0, 0)\nfor _ in range(r):\n\tarr.append(list(input()))\nfor i in range(r):\n\tfor j in range(c):\n\t\tif arr[i][j] == 'S':\n\t\t\tflag = 1\n\t\t\tbreak\n\tif flag == 0:\n\t\tfor j in range(c):\n\t\t\tif arr[i][j] == '.':\n\t\t\t\tarr[i][j] = 'E'\n\t\t\t\tans += 1\n\tflag = 0\nflag = 0\nfor i in range(c):\n\tfor j in range(r):\n\t\tif arr[j][i] == 'S':\n\t\t\tflag = 1\n\t\t\tbreak\n\tif flag == 0:\n\t\tfor j in range(r):\n\t\t\tif arr[j][i] == '.':\n\t\t\t\tans += 1\n\t\t\t\tarr[j][i] = 'E'\n\tflag = 0\nprint(ans)\n", "import sys\nfrom math import sqrt, gcd, ceil, log, floor\nfrom collections import defaultdict, Counter, deque\nfrom heapq import heapify, heappush, heappop\ninput = sys.stdin.readline\nread = lambda : list(map(int, input().strip().split()))\n\ndef main():\n\t(n, m) = read()\n\tarr = []\n\trow = set()\n\tcol = set()\n\tfor i in range(n):\n\t\ts = input().strip()\n\t\tfor j in range(m):\n\t\t\tif s[j] == 'S':\n\t\t\t\trow.add(i)\n\t\t\t\tcol.add(j)\n\tans = (n - len(row)) * m + (m - len(col)) * n - (n - len(row)) * (m - len(col))\n\tprint(ans)\nmain()\n", "(r, c) = map(int, input().split())\nrow = []\ncol = []\narr = []\nfor i in range(r):\n\tline = input()\n\tarr.append(line)\n\tif 'S' not in line:\n\t\trow.append(i)\nfor j in range(c):\n\tcount = 0\n\tfor i in range(r):\n\t\tif arr[i][j] != 'S':\n\t\t\tcount = count + 1\n\tif count == r:\n\t\tcol.append(j)\nans = len(row) * c + len(col) * r - len(row) * len(col)\nprint(ans)\n", "(row, c) = map(int, input().split())\narr = []\nfor _ in range(row):\n\tarr.append([k for k in map(str, input())])\ncakes = 0\nrow_cn = 0\nfor r in arr:\n\tif r.count('.') == c:\n\t\tcakes += c\n\t\trow_cn += 1\nfor col in zip(*arr):\n\tif col.count('.') == row:\n\t\tcakes += row - row_cn\nprint(cakes)\n", "(r, c) = map(int, input().split())\ncake = []\neat = 0\nTransCake = []\nfor i in range(r):\n\tcake.append(input())\nfor i in range(r):\n\tif 'S' in cake[i]:\n\t\tcontinue\n\telse:\n\t\teat += c\n\t\tcake[i] = '0' * c\nfor i in range(c):\n\tTransCake.append([])\n\tfor j in range(r):\n\t\tTransCake[i].append(cake[j][i])\n\tif 'S' in TransCake[i]:\n\t\tcontinue\n\telse:\n\t\teat += TransCake[i].count('.')\nprint(eat)\n", "(r, c) = [int(x) for x in input().split()]\nlst = []\nfor i in range(r):\n\tt = input()\n\ttemp = []\n\tfor i in range(c):\n\t\ttemp.append(t[i])\n\tlst.append(temp)\ncount = 0\nfor i in range(r):\n\tif 'S' not in lst[i]:\n\t\tfor j in range(c):\n\t\t\tif lst[i][j] == '.':\n\t\t\t\tcount += 1\n\t\t\t\tlst[i][j] = 'e'\nlst2 = []\nfor i in range(c):\n\ttemp2 = []\n\tfor j in range(r):\n\t\ttemp2.append(lst[j][i])\n\tlst2.append(temp2)\nfor i in range(c):\n\tif 'S' not in lst2[i]:\n\t\tfor j in range(r):\n\t\t\tif lst2[i][j] == '.':\n\t\t\t\tcount += 1\n\t\t\t\tlst2[i][j] = 'e'\nprint(count)\n", "(r, c) = [int(i) for i in input().split()]\nmass = []\nres_evil = 0\ncol_evil = 0\nfor i in range(r):\n\ts = input()\n\tmass.append(s)\n\tif s.find('S') != -1:\n\t\tres_evil += 1\nfor j in range(c):\n\tfor i in range(r):\n\t\tif mass[i][j] == 'S':\n\t\t\tcol_evil += 1\n\t\t\tbreak\nprint(r * c - res_evil * col_evil)\n", "import sys\nimport math\nget_string = lambda : sys.stdin.readline().strip()\nget_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))\nget_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))\nget_charList_from_str = lambda : list(sys.stdin.readline().strip())\nget_char_list = lambda : sys.stdin.readline().strip().split()\nget_int = lambda : int(sys.stdin.readline())\npt = lambda x: sys.stdout.write(str(x))\n(r, c) = get_int_list()\nmatrix = [0] * r\nfor i in range(r):\n\tmatrix[i] = get_charList_from_str()\ncount = 0\nfor i in range(r):\n\tif 'S' not in matrix[i]:\n\t\tcount += matrix[i].count('.')\n\t\tmatrix[i] = list(''.join(matrix[i]).replace('.', '#'))\nfor j in range(c):\n\ttemp = [matrix[i][j] for i in range(r)]\n\tif 'S' not in temp:\n\t\tcount += temp.count('.')\nprint(count)\n", "(r, c) = map(int, input().split())\na = []\nk = 0\nfor _ in range(r):\n\tx = str(input())\n\ta.append(x)\nfor _ in range(len(a)):\n\tif 'S' not in a[_]:\n\t\ta[_] = [':'] * c\n\t\tk += c\nb = [[a[j][i] for j in range(len(a))] for i in range(len(a[0]))]\nfor _ in range(len(b)):\n\tif 'S' not in b[_]:\n\t\tk += b[_].count('.')\nprint(k)\n", "(r, c) = map(int, input().split())\ncek = set()\nhasil = 0\nmakan = 0\nfor i in range(r):\n\tmasukan = input()\n\tada = False\n\tfor j in range(c):\n\t\tif masukan[j] == 'S':\n\t\t\tcek.add(j)\n\t\t\tada = True\n\tif not ada:\n\t\thasil += c\n\t\tmakan += 1\nhasil += (c - len(cek)) * (r - makan)\nprint(hasil)\n", "(r, c) = map(int, input().split())\nmm = r * c\nmat = []\nfor i in range(r):\n\ts = input()\n\tmat.append(s)\nans = 0\nrr = 0\ncc = 0\ns = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\tif mat[i][j] == 'S':\n\t\t\trr += 1\n\t\t\tbreak\nfor i in range(c):\n\tfor j in range(r):\n\t\tif mat[j][i] == 'S':\n\t\t\tcc += 1\n\t\t\tbreak\nfor i in range(r):\n\tfor j in range(c):\n\t\tif mat[i][j] == 'S':\n\t\t\ts += 1\nprint(r * c - rr * cc)\n", "(n, m) = map(int, input().split())\na = []\nt = count = 0\nflag = True\nfor i in range(n):\n\ta.append([s for s in input().replace('', ' ').strip().split()])\nfor i in range(n):\n\tif 'S' not in a[i]:\n\t\tt += 1\n\t\tcount += len(a[i])\nfor i in range(m):\n\tflag = True\n\tfor j in range(n):\n\t\tif a[j][i] == 'S':\n\t\t\tflag = False\n\t\telif j == n - 1 and flag:\n\t\t\tcount += n - t\nprint(count)\n", "(x, y) = map(int, input().split())\nl = []\nm = []\nfor i in range(x):\n\ts = input()\n\tfor j in range(y):\n\t\tif s[j] == 'S':\n\t\t\tl.append(i)\n\t\t\tm.append(j)\nprint(x * y - len(list(set(l))) * len(list(set(m))))\n", "(r, c) = (int(x) for x in input().split())\ncake = []\nfor i in range(0, r):\n\tcake.append(list(input()))\neats = 0\nfor i in range(0, r):\n\tflag = 0\n\tcurrEats = 0\n\tfor j in range(0, c):\n\t\tif cake[i][j] == 'S':\n\t\t\tflag = 1\n\t\t\tbreak\n\tif flag != 1:\n\t\tfor j in range(0, c):\n\t\t\tif cake[i][j] == '.':\n\t\t\t\teats = eats + 1\n\t\t\t\tcake[i][j] = '!'\nfor j in range(0, c):\n\tflag = 0\n\tcurrEats = 0\n\tfor i in range(0, r):\n\t\tif cake[i][j] == 'S':\n\t\t\tflag = 1\n\t\t\tbreak\n\tif flag != 1:\n\t\tfor i in range(0, r):\n\t\t\tif cake[i][j] == '.':\n\t\t\t\teats = eats + 1\n\t\t\t\tcake[i][j] = '!'\nprint(eats)\n", "(r, c) = map(int, input().split())\na = [input() for i in range(r)]\nt1 = set()\nt2 = set()\nfor i in range(r):\n\tfor j in range(c):\n\t\tif a[i][j] == 'S':\n\t\t\tt1.add(i)\n\t\t\tt2.add(j)\nn = r - len(t1)\nm = c - len(t2)\nprint(n * c + m * r - n * m)\n", "a = [int(i) for i in input().split(' ')]\nrows = a[0]\ncols = a[1]\na = [[x for x in input()] for i in range(rows)]\nc = 0\nfor i in range(rows):\n\tif a[i].count('S') == 0:\n\t\tfor j in range(cols):\n\t\t\tif a[i][j] == '.':\n\t\t\t\ta[i][j] = 'e'\n\t\t\t\tc += 1\nfor i in range(cols):\n\tb = []\n\tfor x in range(rows):\n\t\tb.append(a[x][i])\n\tif b.count('S') == 0:\n\t\tfor j in range(rows):\n\t\t\tif b[j] == '.':\n\t\t\t\ta[j][i] = 'e'\n\t\t\t\tc += 1\nprint(c)\n", "(r, c) = map(int, input().split())\ncounter = 0\nd = []\nstep = 0\nfor i in range(r):\n\ts = input()\n\tif 'S' in s:\n\t\tfor j in range(len(s)):\n\t\t\tif s[j] == 'S':\n\t\t\t\td.append(j)\n\telse:\n\t\tcounter += 1\n\t\tstep += c\nd = set(d)\nfor i in range(c):\n\tif i not in d:\n\t\tstep += r - counter\nprint(step)\n", "(n, m) = map(int, input().split())\nlis = []\nfor i in range(n):\n\tl = list(input())\n\tlis.append(l)\nans = 0\nfor i in range(n):\n\tc = 0\n\tfor j in range(m):\n\t\tif lis[i][j] == 'S':\n\t\t\tc = 0\n\t\t\tbreak\n\t\telif lis[i][j] == '.':\n\t\t\tc += 1\n\tif c > 0:\n\t\tans += c\n\t\tfor j in range(m):\n\t\t\tif lis[i][j] != 'S':\n\t\t\t\tlis[i][j] = 0\nfor i in range(m):\n\tc = 0\n\tfor j in range(n):\n\t\tif lis[j][i] == 'S':\n\t\t\tc = 0\n\t\t\tbreak\n\t\telif lis[j][i] == '.':\n\t\t\tc += 1\n\tif c > 0:\n\t\tans += c\n\t\tfor j in range(n):\n\t\t\tif lis[j][i] != 'S':\n\t\t\t\tlis[j][i] = 0\nprint(ans)\n", "(r, c) = map(int, input().split())\na = [[]]\nx = set()\ny = set()\nfor i in range(r):\n\ta.insert(i, list(input()))\nfor i in range(r):\n\tfor j in range(c):\n\t\tif a[i][j] == 'S':\n\t\t\tx.add(j)\n\t\t\ty.add(i)\nprint(r * c - len(x) * len(y))\n", "(r, c) = [int(i) for i in input().split()]\nlst = []\nberries = [set(), set()]\nfor i in range(r):\n\tlst.append(input())\n\tfor j in range(c):\n\t\tif lst[i][j] == 'S':\n\t\t\tberries[0].add(i)\n\t\t\tberries[1].add(j)\ncells = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\tif lst[i][j] == '.' and (i not in berries[0] or j not in berries[1]):\n\t\t\tcells += 1\nprint(cells)\n", "s = input().split()\na = int(s[0])\nb = int(s[1])\nmat = []\nsat = []\npat = []\nres = 0\nfor i in range(a):\n\tf = input()\n\tfor l in f:\n\t\tpat.append(l)\n\tmat.append(pat)\n\tpat = []\nfor i in range(a):\n\tif 'S' in mat[i]:\n\t\tpass\n\telse:\n\t\tfor j in range(b):\n\t\t\tif mat[i][j] == '.':\n\t\t\t\tres += 1\n\t\t\t\tmat[i][j] = 't'\nfor i in range(b):\n\tfor j in range(a):\n\t\tsat.append(mat[j][i])\n\tif not 'S' in sat:\n\t\tfor k in sat:\n\t\t\tif k == '.':\n\t\t\t\tres += 1\n\tsat = []\nprint(res)\n", "(r, c) = map(int, input().split())\nli = [[0 for i in range(c)] for j in range(r)]\nfor i in range(r):\n\tstring = input()\n\tfor j in range(c):\n\t\tli[i][j] = string[j]\ncount = 0\nflag = True\nfor i in range(r):\n\tfor j in range(c):\n\t\tif li[i][j] == 'S':\n\t\t\tflag = False\n\t\t\tbreak\n\tif flag:\n\t\tfor j in range(c):\n\t\t\tif li[i][j] != '-':\n\t\t\t\tcount += 1\n\t\t\t\tli[i][j] = '-'\n\tflag = True\nflag = True\nfor j in range(c):\n\tfor i in range(r):\n\t\tif li[i][j] == 'S':\n\t\t\tflag = False\n\t\t\tbreak\n\tif flag:\n\t\tfor i in range(r):\n\t\t\tif li[i][j] != '-':\n\t\t\t\tcount += 1\n\t\t\t\tli[i][j] = '-'\n\tflag = True\nprint(count)\n", "from sys import stdin, stdout\ninput = stdin.readline\n(r, s) = map(int, input().split())\ncake = [list(input()) for _ in range(r)]\nfor i in range(r):\n\tif not 'S' in cake[i]:\n\t\tcake[i] = ['#'] * s\nfor i in range(s):\n\tf = False\n\tfor j in range(r):\n\t\tif cake[j][i] == 'S':\n\t\t\tf = True\n\tif not f:\n\t\tfor j in range(r):\n\t\t\tcake[j][i] = '#'\nans = 0\nfor i in cake:\n\tans += i.count('#')\nstdout.write(str(ans))\n", "(n, m) = map(int, input().split())\ng = [input() for i in range(n)]\nprint(n * m - len([1 for i in g if 'S' in i]) * len([1 for i in zip(*g) if 'S' in i]))\n", "import math\nfrom collections import *\nimport sys\nfrom functools import reduce\n\ndef get_ints():\n\treturn map(int, input().strip().split())\n\ndef get_list():\n\treturn list(get_ints())\n\ndef get_string():\n\treturn list(input().strip().split())\n\ndef printxsp(*args):\n\treturn print(*args, end='')\n\ndef printsp(*args):\n\treturn print(*args, end=' ')\nUGLYMOD = int(1000000000.0) + 7\nSEXYMOD = 998244353\nMAXN = int(100000.0)\n(n, m) = get_ints()\nrows = set()\ncols = set()\nmatr = []\nfor i in range(n):\n\tmatr.append(list(input()))\nfor i in range(n):\n\tfor j in range(m):\n\t\tif matr[i][j] == 'S':\n\t\t\trows.add(i)\n\t\t\tcols.add(j)\nprint(n * m - len(rows) * len(cols))\n", "(length, width) = map(int, input().split())\nans = []\ncnt = 0\nfor x in range(length):\n\tans.append(list(input()))\nfor (index, x) in enumerate(ans):\n\tif 'S' not in x:\n\t\tcnt += len(x)\n\t\tans[index] = []\nans = [x for x in ans if x != []]\ncnt2 = 0\ntry:\n\tfor x in range(len(ans[0])):\n\t\tfor z in ans:\n\t\t\tif z[x] != 'S':\n\t\t\t\tcnt2 += 1\n\t\t\telse:\n\t\t\t\tcnt2 = 0\n\t\t\t\tbreak\n\t\telse:\n\t\t\tcnt += cnt2\n\t\t\tcnt2 = 0\nexcept IndexError:\n\tpass\nprint(cnt)\n", "(r, c) = (int(x) for x in input().split())\nfield = []\nfor x in range(r):\n\tfield.append([x for x in input()])\nans = 0\nfor y in range(c):\n\thas_s = False\n\tfor x in range(r):\n\t\tif field[x][y] == 'S':\n\t\t\thas_s = True\n\t\t\tbreak\n\tif not has_s:\n\t\tfor x in range(r):\n\t\t\tif field[x][y] == '.':\n\t\t\t\tans += 1\n\t\t\t\tfield[x][y] = 0\nfor x in range(r):\n\tif 'S' not in field[x]:\n\t\tfor y in range(c):\n\t\t\tif field[x][y] == '.':\n\t\t\t\tans += 1\n\t\t\t\tfield[x][y] = 0\nprint(ans)\n", "(n, m) = map(int, input().split())\nA = []\ncells = 0\nfor i in range(n):\n\ta = input()\n\tA.append(a)\nfor i in range(len(A)):\n\tif 'S' not in A[i]:\n\t\tfor j in A[i]:\n\t\t\tif j == '.':\n\t\t\t\tcells += 1\n\t\t\t\tA[i] = A[i].replace(j, '*')\nt = ''\nB = []\nfor i in range(m):\n\tfor j in A:\n\t\tt += j[i]\n\tB.append(t)\n\tt = ''\nfor i in B:\n\tif 'S' not in i:\n\t\tfor j in i:\n\t\t\tif j == '.':\n\t\t\t\tcells += 1\nprint(cells)\n", "(n, m) = map(int, input().split())\na = []\nt = 0\ns = 0\nfor i in range(n):\n\ta.append(input())\nfor i in range(n):\n\tfor j in range(m):\n\t\tif 'S' not in a[i]:\n\t\t\tt += 1\nb = []\nc = []\nfor i in range(m):\n\tfor j in range(n):\n\t\tif 'S' in a[j][i]:\n\t\t\tb.append(i)\n\t\telif i not in c:\n\t\t\tc.append(i)\nfor i in range(len(b)):\n\tif b[i] in c:\n\t\tc.remove(b[i])\ns = t + len(c) * n\nprint(s - t // m * len(c))\n", "(r, c) = map(int, input().split())\na = []\nb = list(([] for j in range(c)))\nn = 0\nfor i in range(r):\n\ts = input()\n\tif not 'S' in s:\n\t\tn += c\n\telse:\n\t\tfor k in range(c):\n\t\t\tb[k] += s[k]\nfor k in b:\n\tif not 'S' in k:\n\t\tn += k.count('.')\nprint(n)\n", "(ro, co) = map(int, input().split())\nrow = []\nk = 0\nrou = 0\nfor i in range(ro):\n\trow.append(list(input()))\n\tif 'S' not in row[i]:\n\t\trou += 1\n\t\tk += co\nfor i in range(co):\n\tl = 0\n\tfor j in range(ro):\n\t\tif row[j][i] == 'S':\n\t\t\tl = 1\n\t\t\tbreak\n\tif l == 0:\n\t\tk += ro - rou\nprint(k)\n", "(r, c) = [int(elem) for elem in input().split()]\ncake = [''] * r\nfor i in range(r):\n\tcake[i] = input()\ncoloms = [str(elem) for elem in list(range(c))]\nfor i in range(len(cake)):\n\tfor j in range(len(cake[0])):\n\t\tif cake[i][j] == 'S':\n\t\t\tif coloms.count(str(j)) != 0:\n\t\t\t\tcoloms.remove(str(j))\ncount = len(coloms) * r\nrows = [str(elem) for elem in list(range(r))]\nfor i in range(len(cake)):\n\tfor j in range(len(cake[0])):\n\t\tif cake[i][j] == 'S':\n\t\t\tif rows.count(str(i)) != 0:\n\t\t\t\trows.remove(str(i))\ncount += len(rows) * (c - len(coloms))\nprint(count)\n", "(r, c) = map(int, input().split(' '))\ncount = 0\nA = []\nx = 0\nfor i in range(r):\n\tn = list(input())\n\tif 'S' not in n:\n\t\tx += 1\n\tA.append(n)\ny = []\np = 0\nfor i in range(c):\n\tfor j in range(r):\n\t\ty.append(A[j][i])\n\tif 'S' not in y:\n\t\tp += 1\n\ty = []\ncount = r * c - (r - x) * (c - p)\nprint(count)\n", "s = input().split()\n(r, c) = (int(s[0]), int(s[1]))\nl = [None] * r\ncnt_r = cnt_c = 0\nfor i in range(r):\n\ts = input()\n\tif s.find('S') == -1:\n\t\tcnt_r += 1\n\tl[i] = s\ntl = [''.join(s) for s in zip(*l)]\nfor i in range(c):\n\tif tl[i].find('S') == -1:\n\t\tcnt_c += 1\nprint(cnt_r * c + cnt_c * r - cnt_r * cnt_c)\n", "(r, c) = map(int, input().split())\nrows = 0\ncols = 0\nlines = []\nfor i in range(r):\n\trow = input()\n\tlines.append(row)\n\tif 'S' in row:\n\t\trows += 1\nfor i in range(c):\n\tcol = ''\n\tfor j in range(r):\n\t\tcol += lines[j][i]\n\tif 'S' in col:\n\t\tcols += 1\nprint(r * c - rows * cols)\n", "st = input().split()\nr = int(st[0])\nc = int(st[1])\ng = []\nblk = ''\nfor i in range(c):\n\tblk += '_'\nfor i in range(r):\n\tg.append(input())\neaten = 0\nfor i in range(r):\n\tif not 'S' in str(g[i]):\n\t\teaten += c\n\t\tg[i] = blk\nfor i in range(c):\n\teadible = True\n\tfor j in range(r):\n\t\tif g[j][i] == 'S':\n\t\t\teadible = False\n\tif eadible:\n\t\tfor j in range(r):\n\t\t\tif g[j][i] == '.':\n\t\t\t\teaten += 1\nprint(eaten)\n", "(r, c) = map(int, input().split())\nlist1 = []\nfor i in range(r):\n\tll = list(input())\n\tlist1.append(ll)\nx = 0\ny = 0\nlr = []\nlc = []\nfor i in range(r):\n\tf = 0\n\tfor j in range(c):\n\t\tif list1[i][j] == 'S':\n\t\t\tf = 1\n\tif f == 0:\n\t\tx += 1\n\telse:\n\t\tlr.append(i)\nfor i in range(c):\n\tf = 0\n\tfor j in range(r):\n\t\tif list1[j][i] == 'S':\n\t\t\tf = 1\n\tif f == 0:\n\t\ty += 1\n\telse:\n\t\tlc.append(i)\ncount = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\tif i in lr and j in lc:\n\t\t\tcount += 1\nprint(r * c - count)\n", "def solve(r, c, cake):\n\t(rows, collumns) = (set(), set())\n\tfor (i, row) in enumerate(cake):\n\t\tfor (j, cell) in enumerate(row):\n\t\t\tif cell == 'S':\n\t\t\t\trows.add(i)\n\t\t\t\tcollumns.add(j)\n\treturn r * c - len(rows) * len(collumns)\n(r, c) = map(int, input().split())\nl = []\nfor _ in range(r):\n\tl.append(input())\nprint(solve(r, c, l))\n", "def tran(m):\n\trez = [[m[j][i] for j in range(len(m))] for i in range(len(m[0]))]\n\treturn rez\n(r, n) = map(int, input().strip().split())\nc = 0\nb = 0\narr = []\nfor l in range(r):\n\tarr.append(list(input()))\nfor row in arr:\n\tif 'S' not in row:\n\t\tc += row.count('.')\n\t\tb += 1\narr = tran(arr)\nfor row in arr:\n\tif 'S' not in row:\n\t\tc += row.count('.') - b\nprint(c)\n", "(r, c) = map(int, input().split())\nl = []\npr = set()\npc = set()\nfor i in range(r):\n\tl.append(input())\n\tif 'S' in l[i]:\n\t\tpr.add(i)\n\t\tfor (idx, element) in enumerate(l[i]):\n\t\t\tif element == 'S':\n\t\t\t\tpc.add(idx)\ncells = (r - len(pr)) * c\ncells += (c - len(pc)) * len(pr)\nprint(cells)\n", "(r, c) = map(int, input().split())\narr = []\nrows = 0\ncols = 0\nfor i in range(r):\n\tarr.append(input())\nfor i in range(r):\n\tif 'S' not in arr[i]:\n\t\trows += 1\nfor i in range(c):\n\ttemp = 0\n\tfor j in range(r):\n\t\tif arr[j][i] != 'S':\n\t\t\ttemp += 1\n\tif temp == r:\n\t\tcols += 1\nprint(rows * c + cols * r - rows * cols)\n", "rc = input().split()\nr = int(rc[0])\nc = int(rc[1])\nl = []\nx = 0\ny = 0\nfor i in range(r):\n\tl.append(input())\nfor i in range(r):\n\tfor j in range(c):\n\t\tif l[i][j] == 'S':\n\t\t\tx = x + 1\n\t\t\tbreak\nfor i in range(c):\n\tfor j in range(r):\n\t\tif l[j][i] == 'S':\n\t\t\ty = y + 1\n\t\t\tbreak\nprint(r * c - x * y)\n", "(r, c) = list(map(int, input().split()))\np = ''\nx = y = 0\nfor i in range(r):\n\ta = input()\n\tp = p + a\n\tif a.count('S') == 0:\n\t\tx = x + c\nfor i in range(c):\n\tif p[i::c].count('S') == 0:\n\t\ty = y + r - x // c\nprint(x + y)\n", "(n, m) = list(map(int, input().split()))\nxl = []\nl = []\nfor _ in range(n):\n\txl.append(list(input()))\nc = 0\nl = xl.copy()\nfor x in xl:\n\tif 'S' not in x:\n\t\tc += m\n\t\tl.remove(x)\nnl = list(map(list, zip(*l)))\nfor x in nl:\n\tif 'S' not in x:\n\t\tc += len(x)\nprint(c)\n", "x = [int(x) for x in input().split()]\nr = x[0]\nc = x[1]\na = 0\nv = []\nfor i in range(r):\n\tit = input()\n\tv.append(it)\n\tif it.count('S') == 0:\n\t\ta += 1\nb = 0\nfor j in range(c):\n\tl = ''\n\tfor k in range(r):\n\t\tl += v[k][j]\n\tif l.count('S') == 0:\n\t\tb += 1\nprint(a * c + b * r - a * b)\n", "(r, c) = map(int, input().split())\nmas = [list(input()) for i in range(r)]\nfor i in range(r):\n\tif not 'S' in mas[i]:\n\t\tmas[i] = [1] * c\nfor p in range(c):\n\tfind_S = False\n\tfor i in range(r):\n\t\tif mas[i][p] == 'S':\n\t\t\tfind_S = True\n\t\t\tbreak\n\tif not find_S:\n\t\tfor i in range(r):\n\t\t\tmas[i][p] = 1\nk = 0\nfor m in mas:\n\tk += m.count(1)\nprint(k)\n", "row = {}\ncolumn = {}\n(n, m) = map(int, input().split())\nmatrix = []\nfor i in range(n):\n\tmatrix.append(list(input()))\nfor i in range(n):\n\trow[i] = False\nfor j in range(m):\n\tcolumn[j] = False\nfor i in range(n):\n\tfor j in range(m):\n\t\tif matrix[i][j] == 'S':\n\t\t\trow[i] = True\n\t\t\tcolumn[j] = True\ncnt = m * n\nfor i in range(n):\n\tfor j in range(m):\n\t\tif matrix[i][j] == 'S' or (row[i] and column[j]):\n\t\t\tcnt -= 1\nprint(cnt)\n", "(r, c) = list(map(int, input().split()))\nl = []\na = []\nfor i in range(r):\n\tl.append(input())\ncnt = 0\nfor (ix, row) in enumerate(l):\n\tif 'S' not in row:\n\t\tcnt += c\n\t\ta.append(ix)\ni = j = 0\nwhile j < c:\n\tcn = i = 0\n\twhile i < r:\n\t\tif i in a:\n\t\t\ti += 1\n\t\t\tcontinue\n\t\tif l[i][j] == 'S':\n\t\t\tbreak\n\t\telse:\n\t\t\tcn += 1\n\t\ti += 1\n\telse:\n\t\tcnt += cn\n\tj += 1\nprint(cnt)\n", "(n, m) = map(int, input().split())\nst = [input() for _ in range(n)]\ncol = []\nfor j in range(m):\n\ta = ''\n\tfor i in range(n):\n\t\ta += st[i][j:j + 1]\n\tcol.append(a)\ncount = 0\ncount_st = 0\nfor i in range(n):\n\tif 'S' not in st[i]:\n\t\tcount += m\n\t\tcount_st += 1\nfor j in range(m):\n\tif 'S' not in col[j]:\n\t\tcount += n - count_st\nprint(count)\n", "(r, c) = input().split()\n(r, c) = (int(r), int(c))\nlis = []\nfor i in range(r):\n\tlis.append(input())\n\tlis[i] = list(lis[i])\ncount = lis.count(['.' for j in range(c)])\ncake = count * c\nlis1 = []\nfor k in lis:\n\tif k != ['.' for j in range(c)]:\n\t\tlis1.append(k)\nlis2 = [[0 for i in range(r - count)] for j in range(c)]\nfor i in range(r - count):\n\tfor j in range(c):\n\t\tlis2[j][i] = lis1[i][j]\ncake += lis2.count(['.' for j in range(r - count)]) * (r - count)\nprint(cake)\n", "def cake(n, m, grid):\n\tc = 0\n\tr = 0\n\tfor i in grid:\n\t\tif 'S' in i:\n\t\t\tr += 1\n\tnew = []\n\tfor i in range(m):\n\t\ttemp = []\n\t\ttemp = [grid[j][i] for j in range(n)]\n\t\tnew.append(temp)\n\tfor i in new:\n\t\tif 'S' in i:\n\t\t\tc += 1\n\treturn n * m - r * c\nlst = [int(x) for x in input().split()]\nn = lst[0]\nm = lst[1]\ngrid = []\nfor i in range(n):\n\ts = input()\n\ttemp = []\n\ttemp.extend(s)\n\tgrid.append(temp)\nprint(cake(n, m, grid))\n", "(n, M) = map(int, input().split())\nA = []\nB = []\nfor i in range(n):\n\tm = input()\n\tfor j in range(len(m)):\n\t\tif m[j] == 'S':\n\t\t\tif not j in B:\n\t\t\t\tB.append(j)\n\t\t\tif not i in A:\n\t\t\t\tA.append(i)\ns = 0\ns += M * (n - len(A))\ns += len(A) * (M - len(B))\nprint(s)\n", "(R, C) = map(int, input().split())\nG = [list(input()) for r in range(R)]\n\ndef count_cells(R, C):\n\tret = 0\n\tfor r in range(R):\n\t\tvalid = True\n\t\tfor c in range(C):\n\t\t\tif G[r][c] == 'S':\n\t\t\t\tvalid = False\n\t\t\t\tbreak\n\t\tif valid:\n\t\t\tfor c in range(C):\n\t\t\t\tif G[r][c] == '.':\n\t\t\t\t\tret += 1\n\t\t\t\t\tG[r][c] = 'X'\n\tfor c in range(C):\n\t\tvalid = True\n\t\tfor r in range(R):\n\t\t\tif G[r][c] == 'S':\n\t\t\t\tvalid = False\n\t\t\t\tbreak\n\t\tif valid:\n\t\t\tfor r in range(R):\n\t\t\t\tif G[r][c] == '.':\n\t\t\t\t\tret += 1\n\t\t\t\t\tG[r][c] = 'X'\n\treturn ret\nprint(count_cells(R, C))\n", "(r, c) = map(int, input().split())\nmaze = []\nfor i in range(r):\n\tmaze.append(input())\nrr = [True for _ in range(r)]\ncc = [True for _ in range(c)]\nfor i in range(r):\n\tfor j in range(c):\n\t\tif maze[i][j] == 'S':\n\t\t\trr[i] = False\n\t\t\tcc[j] = False\nans = 0\nrtrue = 0\nfor i in range(r):\n\tif rr[i]:\n\t\tans += c\n\t\trtrue += 1\nctrue = 0\nfor j in range(c):\n\tif cc[j]:\n\t\tans += r\n\t\tctrue += 1\nans -= rtrue * ctrue\nprint(ans)\n", "import sys\nfrom math import *\ninput = sys.stdin.readline\nRI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]\nrw = lambda : input().strip().split()\nfrom collections import defaultdict as df\nimport heapq\ninfinite = float('inf')\n(n, m) = RI()\nl = [[] for i in range(n)]\nfor i in range(n):\n\tl[i] = list(input().strip())\nfor i in range(n):\n\tf = 0\n\tfor j in range(m):\n\t\tif l[i][j] == 'S':\n\t\t\tf = 1\n\t\t\tbreak\n\tif f == 0:\n\t\tfor j in range(m):\n\t\t\tl[i][j] = 1\nfor i in range(m):\n\tf = 0\n\tfor j in range(n):\n\t\tif l[j][i] == 'S':\n\t\t\tf = 1\n\t\t\tbreak\n\tif f == 0:\n\t\tfor j in range(n):\n\t\t\tl[j][i] = 1\nc = 0\nfor i in range(n):\n\tfor j in range(m):\n\t\tif l[i][j] == 1:\n\t\t\tc += 1\nprint(c)\n", "(r, c) = list(map(int, input().split()))\n(l, S) = ([], [[], []])\nh_sum = 0\nv_sum = 0\nintersects = 0\nfor i in range(r):\n\tl.append(input())\nfor i in range(c):\n\tcount = 0\n\tfor j in range(r):\n\t\tif l[j][i] == '.':\n\t\t\tcount += 1\n\tif count == r:\n\t\th_sum += r\nfor i in range(r):\n\tcount = 0\n\tfor j in range(c):\n\t\tif l[i][j] == '.':\n\t\t\tcount += 1\n\tif count == c:\n\t\tv_sum += c\nfor i in range(r):\n\tfor j in range(c):\n\t\tif l[i][j] == 'S':\n\t\t\tS[0].append(i)\n\t\t\tS[1].append(j)\nfor i in range(r):\n\tif i not in S[0]:\n\t\tfor j in range(c):\n\t\t\tif j not in S[1]:\n\t\t\t\tintersects += 1\nprint(h_sum + v_sum - intersects)\n", "(n, m) = map(int, input().split())\nrow_flags = [False] * n\ncol_flags = [False] * m\nfor i in range(n):\n\thas_s = False\n\tfor (j, v) in enumerate(input()):\n\t\tif v == 'S':\n\t\t\thas_s = True\n\t\t\tcol_flags[j] = True\n\tif has_s:\n\t\trow_flags[i] = True\nprint(n * m - sum(row_flags) * sum(col_flags))\n", "(n, m) = map(int, input().split())\nli = []\nans = 0\nfor i in range(n):\n\ts = list(input())\n\tif 'S' not in s:\n\t\tans += m\n\telse:\n\t\tli.append(s)\nif len(li) != 0:\n\tli2 = []\n\tfor i in range(len(li[0])):\n\t\tx = []\n\t\tfor j in li:\n\t\t\tx.append(j[i])\n\t\tif 'S' not in x:\n\t\t\tans += len(x)\nprint(ans)\n", "(r, c) = map(int, input().split())\na = []\nnr = []\nnc = []\nfor i in range(r):\n\tp = list(input())\n\tfor j in range(c):\n\t\tif p[j] == 'S':\n\t\t\tif j not in nc:\n\t\t\t\tnc.append(j)\n\t\t\tif i not in nr:\n\t\t\t\tnr.append(i)\nprint((r - len(nr)) * c + (c - len(nc)) * r - (r - len(nr)) * (c - len(nc)))\n", "(r, c) = [int(item) for item in input().split()]\nmat = [[s for s in input()] for _ in range(r)]\ncount = 0\nrows = 0\ncols = set()\nd = {}\nfor i in range(r):\n\tif 'S' not in mat[i]:\n\t\trows += 1\n\tfor j in range(c):\n\t\tif 'S' == mat[i][j]:\n\t\t\tcols.add(j)\ncount = (c - len(cols)) * (r - rows) + rows * c\nprint(count)\n", "(m, n) = map(int, input().split(' '))\nm_set = set()\nn_set = set()\nfor a in range(m):\n\ts = input()\n\tfor (b, c) in enumerate(s):\n\t\tif c == 'S':\n\t\t\tm_set.add(a)\n\t\t\tn_set.add(b)\nprint(m * n - len(m_set) * len(n_set))\n", "def main():\n\t(r, c) = [int(i) for i in input().split()]\n\terow = []\n\tecol = []\n\tcount = 0\n\tfor i in range(r):\n\t\ts = input()\n\t\tfor col in range(c):\n\t\t\tif s[col] == 'S':\n\t\t\t\terow.append(i)\n\t\t\t\tecol.append(col)\n\tfor i in range(r):\n\t\tfor j in range(c):\n\t\t\tif i in erow and j in ecol:\n\t\t\t\tpass\n\t\t\telse:\n\t\t\t\tcount += 1\n\tprint(count)\n\treturn 0\nmain()\n", "(r, c) = [int(i) for i in input().split()]\ns = 0\nl = []\nnum = 0\nnu = 0\nfor i in range(r):\n\ta = input()\n\tif 'S' not in a:\n\t\ts += c\n\t\tnum += 1\n\tl.append(a)\nfor i in range(c):\n\tk = 0\n\tfor j in range(r):\n\t\tif l[j][i] == 'S':\n\t\t\tbreak\n\t\telse:\n\t\t\tk += 1\n\tif k == r:\n\t\ts += r\n\t\tnu += 1\nprint(s - num * nu)\n", "(r, c) = map(int, input().split())\narr = []\nrow = []\ncol = []\ntotal = tot = 0\nfor i in range(r):\n\tarr.append(input())\nfor i in range(r):\n\tfor j in range(c):\n\t\tif arr[i][j] == 'S':\n\t\t\trow.append(i)\n\t\t\tcol.append(j)\nfor i in range(r):\n\tif i not in row:\n\t\ttot += c\nfor j in range(c):\n\tif j not in col:\n\t\ttotal += r - tot // c\nprint(total + tot)\n", "(a, b) = map(int, input().split())\neat = 0\nate = 0\ncake = []\nfor i in range(a):\n\tx = list(input())\n\tcake.append(x)\n\tif 'S' not in x:\n\t\teat += b\n\t\tate += 1\nfor j in range(b):\n\tstat = 'clean'\n\tfor k in range(a):\n\t\tif cake[k][j] == 'S':\n\t\t\tstat = 'evil'\n\tif stat == 'clean':\n\t\teat += a - ate\nprint(eat)\n", "(n, m) = (int(i) for i in input().split())\nl = [input() for i in range(n)]\na = []\nfor i in range(n):\n\tfor j in range(m):\n\t\tif l[i][j] == 'S':\n\t\t\ta.append([i, j])\nfor i in range(len(a)):\n\tfor j in range(len(a)):\n\t\tif [a[i][0], a[j][1]] not in a:\n\t\t\ta.append([a[i][0], a[j][1]])\nprint(n * m - len(a))\n", "def main():\n\t(r, c) = map(int, input().split())\n\tk = list()\n\tfor i in range(r):\n\t\tk.append([char for char in input()])\n\tcolumns = 0\n\trows = 0\n\tfor i in range(r):\n\t\tif 'S' not in k[i]:\n\t\t\trows += 1\n\tfor i in range(c):\n\t\tif 'S' not in [k[j][i] for j in range(r)]:\n\t\t\tcolumns += 1\n\tprint(rows * c + columns * r - rows * columns)\nmain()\n", "(r, c) = list(map(int, input().split()))\nq = []\nfor i in range(0, r):\n\ta = input()\n\tp = []\n\tfor j in a:\n\t\tp.append(j)\n\tq.append(p)\nz = 0\nw = 0\nfor i in range(0, r):\n\tif 'S' not in q[i]:\n\t\tw = w + 1\n\t\tz = z + c\nfor i in range(0, c):\n\tf = 0\n\tfor j in range(0, r):\n\t\tif q[j][i] == 'S':\n\t\t\tf = 1\n\t\t\tbreak\n\tif f == 0:\n\t\tz = z + r - w\nprint(z)\n", "(r, c) = map(int, input().split())\nspiska = []\nrrr = []\nccc = []\nfor i in range(r):\n\tspiska.append(input().strip())\nfor i in range(r):\n\tfor j in range(c):\n\t\tif spiska[i][j] == 'S':\n\t\t\trrr.append(i + 1)\n\t\t\tccc.append(j + 1)\nrrr = set(rrr)\nccc = set(ccc)\nprint((r - len(rrr)) * c + (c - len(ccc)) * r - (r - len(rrr)) * (c - len(ccc)))\n", "(n, m) = list(map(int, input().split()))\narr = [input() for _ in range(n)]\nset1 = []\nset2 = []\nfor i in range(n):\n\tfor j in range(m):\n\t\tif arr[i][j] == 'S':\n\t\t\tset1.append(i)\n\t\t\tset2.append(j)\nlen1 = int(n - len(set(set1)))\nlen2 = int(m - len(set(set2)))\nprint(len1 * m + len2 * n - len2 * len1)\n", "(a, b) = tuple(map(int, input().split()))\nfree_rows = [i for i in range(a)]\nfree_cols = [i for i in range(b)]\nfor i in range(a):\n\trow = input()\n\tif 'S' in row:\n\t\tfree_rows.remove(i)\n\tfor j in range(b):\n\t\tif row[j] == 'S':\n\t\t\tif j in free_cols:\n\t\t\t\tfree_cols.remove(j)\nprint(len(free_rows) * b + len(free_cols) * a - len(free_rows) * len(free_cols))\n", "(n, m) = list(map(int, input().split()))\na = []\nfor _ in range(n):\n\ta.append(input())\nrow = set()\ncolumn = set()\nfor i in range(len(a)):\n\tfor j in range(len(a[i])):\n\t\tif a[i][j] == 'S':\n\t\t\trow.add(j)\n\t\t\tcolumn.add(i)\nprint((n - len(column)) * m + (m - len(row)) * n - (n - len(column)) * (m - len(row)))\n", "(r, c) = map(int, input().split())\nl = []\nfor i in range(r):\n\ts = input()\n\tl.append(s)\na = []\nfor i in range(r):\n\tb = 0\n\td = []\n\tfor j in range(c):\n\t\tif l[i][j] == 'S':\n\t\t\tb = 1\n\t\telse:\n\t\t\td.append(j + 1 + i * c)\n\tif b == 0:\n\t\tfor i in d:\n\t\t\ta.append(i)\nfor i in range(c):\n\tb = 0\n\td = []\n\tfor j in range(r):\n\t\tif l[j][i] == 'S':\n\t\t\tb = 1\n\t\t\tbreak\n\t\telse:\n\t\t\td.append(j * c + i + 1)\n\tif b == 0:\n\t\tfor i in d:\n\t\t\ta.append(i)\nprint(len(set(a)))\n", "(n, m) = map(int, input().split())\ntort = [input() for i in range(n)]\nx = 'S'\nmas = [[False] * m for i in range(n)]\nfor i in range(n):\n\tif 'S' not in tort[i]:\n\t\tfor j in range(m):\n\t\t\tmas[i][j] = True\nfor j in range(m):\n\tis_find = False\n\tfor i in range(n):\n\t\tif tort[i][j] == 'S':\n\t\t\tis_find = True\n\t\t\tbreak\n\tif not is_find == True:\n\t\tfor i in range(n):\n\t\t\tmas[i][j] = True\ncount = 0\nfor row in mas:\n\tcount += row.count(True)\nprint(count)\n", "s = input('')\n(n, m) = s.split(' ')\nn = int(n)\nm = int(m)\nl = []\nfor i in range(n):\n\ts1 = input('')\n\tl.append(list(s1))\nl1 = []\nfor i in range(n):\n\ttemp = l[i].count('S')\n\tif temp == 0:\n\t\tfor j in range(m):\n\t\t\tl1.append([i, j])\nl2 = list(map(list, zip(*l)))\nfor i in range(m):\n\ttemp = l2[i].count('S')\n\tif temp == 0:\n\t\tfor j in range(n):\n\t\t\tl1.append([j, i])\nl3 = []\ncount = 0\nfor i in l1:\n\tif i not in l3:\n\t\tl3.append(i)\nprint(len(l3))\n", "(r, c) = map(int, input().split())\ncake = []\neat = r * c\nrows = set()\ncols = set()\nfor i in range(r):\n\tcake.append([i for i in input()])\n\tfor (j, char) in enumerate(cake[i]):\n\t\tif char == 'S':\n\t\t\trows.add(i)\n\t\t\tcols.add(j)\nprint(eat - len(rows) * len(cols))\n", "(n, m) = map(int, input().split())\ns = ''\nsm = 0\nfor _ in range(n):\n\ttemp = input().strip()\n\tif 'S' in temp:\n\t\ts += temp\n\telse:\n\t\tsm += len(temp)\n\t\tn -= 1\nfor i in range(m):\n\tsm += ('S' not in s[i::m]) * n\nprint(sm)\n", "(h, w) = map(int, input().split())\n(can_collums, can_rows) = ([True for i in range(w)], [True for i in range(h)])\ncake = []\nfor row_i in range(h):\n\tline = input()\n\trow = []\n\tfor (collum_i, c) in enumerate(line):\n\t\tif c == 'S':\n\t\t\trow.append(1)\n\t\t\tcan_collums[collum_i] = False\n\t\t\tcan_rows[row_i] = False\n\t\telse:\n\t\t\trow.append(0)\n\tcake.append(row)\ncan = 0\nfor (row_i, row) in enumerate(cake):\n\tcan_row = can_rows[row_i]\n\tfor (collum_i, collum) in enumerate(row):\n\t\tcan_collum = can_collums[collum_i]\n\t\tif can_row or can_collum:\n\t\t\tcan += 1\nprint(can)\n", "(n, m) = map(int, input().split())\narr = []\nmapping = {}\nx = []\ny = []\nans = 0\nfor _ in range(n):\n\tline = input()\n\tfor i in range(m):\n\t\tif line[i] == 'S':\n\t\t\tx.append(_)\n\t\t\ty.append(i)\nfor i in range(n):\n\tfor j in range(m):\n\t\tif i in x and j in y:\n\t\t\tcontinue\n\t\telse:\n\t\t\tans += 1\nprint(ans)\n", "(n, m) = map(int, input().split())\nr = []\nc = []\nt = 0\nd = 0\nfor i in range(n):\n\ta = list(input())\n\tfor j in range(m):\n\t\tif a[j] == 'S':\n\t\t\tr.append(i)\n\t\t\tc.append(j)\n\ta = []\nfor i in range(n):\n\tif i not in r:\n\t\tt += m\n\t\td += 1\nfor i in range(m):\n\tif i not in c:\n\t\tt += n - d\nprint(t)\n", "(r, c) = map(int, input().split())\n(rs, cs) = (set(), set())\nM = []\nfor i in range(r):\n\ta = input()\n\tfor j in range(len(a)):\n\t\tif a[j] == 'S':\n\t\t\tcs.add(j)\n\t\t\trs.add(i)\n\tM += [a]\nan = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\tif M[i][j] == '.' and (i not in rs or j not in cs):\n\t\t\tan += 1\nprint(an)\n", "(r, c) = map(int, input().split())\ncake = []\nfor i in range(r):\n\tcake.append(list(input()))\ncake_transposed = list(zip(*cake))\ncount = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\tif 'S' not in cake[i] or 'S' not in cake_transposed[j]:\n\t\t\tcount = count + 1\nprint(count)\n", "def solve(r, c, cake):\n\tcol = list()\n\tfor i in range(0, c):\n\t\tisColEdible = True\n\t\tisOneCakeAvailable = False\n\t\tfor j in range(0, r):\n\t\t\tif cake[j][i] == '.':\n\t\t\t\tisOneCakeAvailable = True\n\t\t\telif cake[j][i] == 'S':\n\t\t\t\tisColEdible = False\n\t\tif isOneCakeAvailable and isColEdible:\n\t\t\tcol.append(i)\n\trow = list()\n\tallRowsEdibleCount = 0\n\tfor i in range(0, r):\n\t\tthisRowEdibleCount = 0\n\t\tisRowEdible = True\n\t\tisOneCakeAvailable = False\n\t\tfor j in range(0, c):\n\t\t\tif cake[i][j] == '.' and j not in col:\n\t\t\t\tisOneCakeAvailable = True\n\t\t\t\tthisRowEdibleCount += 1\n\t\t\telif cake[i][j] == 'S':\n\t\t\t\tisRowEdible = False\n\t\tif isOneCakeAvailable and isRowEdible:\n\t\t\trow.append(i)\n\t\t\tallRowsEdibleCount += thisRowEdibleCount\n\treturn len(col) * r + allRowsEdibleCount\n(r, c) = map(int, input().split(' '))\ncake = list()\n_r = 0\nwhile _r < r:\n\tcake_line = list()\n\tcake_line = input()\n\tcake.append(cake_line)\n\t_r += 1\nprint(solve(r, c, cake))\n", "data = input().split()\n(R, C) = (int(data[0]), int(data[1]))\ncake = [[None] * C] * R\nfor i in range(R):\n\tcake[i] = input()\neaten_cake = 0\nfor i in range(R):\n\tif cake[i].count('S') == 0:\n\t\teaten_cake += C\n\t\tcake[i] = '1' * C\n\t\tcontinue\nfor j in range(C):\n\tS_flag = 0\n\tfor i in range(R):\n\t\tif cake[i][j] == 'S':\n\t\t\tS_flag = 1\n\t\t\tbreak\n\tif S_flag == 1:\n\t\tcontinue\n\telse:\n\t\tfor i in range(R):\n\t\t\tif cake[i][j] == '.':\n\t\t\t\teaten_cake += 1\nprint(eaten_cake)\n", "import sys\n(r, c) = map(int, sys.stdin.readline().split())\ncake = []\nfor i in range(0, r):\n\tcake.append(input())\ngood_raws = r\ngood_columns = c\nfor i in range(0, r):\n\tk_raws = 0\n\tfor j in range(0, c):\n\t\tif cake[i][j] == 'S':\n\t\t\tk_raws = 1\n\tif k_raws == 1:\n\t\tgood_raws -= 1\nrows_eaten_cells = good_raws * c\nfor j in range(0, c):\n\tk_columns = 0\n\tfor i in range(0, r):\n\t\tif cake[i][j] == 'S':\n\t\t\tk_columns = 1\n\tif k_columns == 1:\n\t\tgood_columns -= 1\ncolumns_eaten_cells = good_columns * (r - good_raws)\nprint(rows_eaten_cells + columns_eaten_cells)\n", "(n, m) = list(map(int, input().split()))\ns = []\na = [True] * (n + 1)\nb = [True] * (m + 1)\nfor i in range(n):\n\ts.append(input())\nx = 0\nfor i in range(n):\n\tfor j in range(m):\n\t\tif s[i][j] == 'S':\n\t\t\ta[i] = False\n\t\t\tb[j] = False\nfor i in range(n):\n\tfor j in range(m):\n\t\tif a[i] or b[j]:\n\t\t\tx += 1\nprint(x)\n", "(num_rows, num_columns) = map(int, input().split())\nnon_empty_rows = set()\nnon_empty_cols = set()\nfor num_row in range(1, num_rows + 1):\n\trow = input()\n\tfor (num_column, char) in enumerate(row, start=1):\n\t\tif char == 'S':\n\t\t\tnon_empty_rows.add(num_row)\n\t\t\tnon_empty_cols.add(num_column)\nnum_empty_rows = num_rows - len(non_empty_rows)\nnum_empty_cols = num_columns - len(non_empty_cols)\nprint(num_empty_rows * num_columns + num_empty_cols * num_rows - num_empty_cols * num_empty_rows)\n", "grid = []\nsize = input().split(' ')\nrows = int(size[0])\ncolumns = int(size[1])\nfor t in range(rows):\n\tgrid.append(input())\nrs = 0\nfor element in grid:\n\tif 'S' in element:\n\t\trs += 1\nclms = 0\nfor clmn in range(columns):\n\tsa = 0\n\tfor element in grid:\n\t\tif element[clmn] == 'S':\n\t\t\tsa = 1\n\tif sa == 1:\n\t\tclms += 1\nprint(rows * columns - rs * clms)\n", "(r, c) = map(int, input().split())\ncell = [input() for i in range(r)]\nrows = []\ncols = []\nfor i in range(r):\n\tfor j in range(c):\n\t\tif cell[i][j] == 'S':\n\t\t\trows.append(i)\n\t\t\tcols.append(j)\nprint(r * c - len(set(rows)) * len(set(cols)))\n", "(n, m) = map(int, input().split())\nans1 = 0\nans2 = 0\nl = [['0' for f1 in range(m)] for f2 in range(n)]\nfor f1 in range(n):\n\ts = input()\n\tfor f2 in range(m):\n\t\tl[f1][f2] = s[f2]\nfor f1 in range(n):\n\tans1 += m\n\tfor f2 in range(m):\n\t\tif l[f1][f2] != '.':\n\t\t\tans1 -= m\n\t\t\tbreak\nfor f1 in range(m):\n\tans2 += n - ans1 / m\n\tfor f2 in range(n):\n\t\tif l[f2][f1] != '.':\n\t\t\tans2 -= n - ans1 / m\n\t\t\tbreak\nprint(int(ans1 + ans2))\n", "(row, col) = map(int, input().split())\ntab = [[i for i in input()] for j in range(row)]\nnum_row = num_col = 0\ntab_2 = []\nfor (ind, i) in enumerate(tab):\n\tif 'S' not in i:\n\t\tnum_row += len(i)\n\telse:\n\t\ttab_2.append(i)\ntmp = 0\nif len(tab_2) == 0:\n\tprint(num_row)\nelse:\n\tfor i in range(len(tab_2[0])):\n\t\tif tmp == 1:\n\t\t\tnum_col += len(tab_2)\n\t\ttmp = 0\n\t\tfor j in range(len(tab_2)):\n\t\t\tif tab_2[j][i] == 'S':\n\t\t\t\ttmp = 0\n\t\t\t\tbreak\n\t\t\ttmp = 1\n\tif tmp == 1:\n\t\tnum_col += len(tab_2)\n\tprint(num_row + num_col)\n", "(a, b) = map(int, input().split())\nl = []\nfor i in range(a):\n\tl.append(input())\nfor i in range(a):\n\tc = 0\n\tfor j in range(b):\n\t\tif l[i][j] != 'S':\n\t\t\tc += 1\n\tif b - c == 0:\n\t\tfor n in range(len(l[i])):\n\t\t\tl[i] = '*' * b\nfor j in range(b):\n\tc = 0\n\tfor i in range(a):\n\t\tif l[i][j] != 'S':\n\t\t\tc += 1\n\tif a - c == 0:\n\t\tfor w in range(a):\n\t\t\ts = list(l[w])\n\t\t\ts[j] = '*'\n\t\t\tl[w] = ''.join(s)\nc = 0\nfor i in range(a):\n\tc += l[i].count('*')\nprint(c)\n", "(r, c) = map(int, input().split())\nrt = [0] * 10\nct = [0] * 10\nfor i in range(r):\n\ts = str(input())\n\tfor j in range(len(s)):\n\t\tif s[j] == 'S':\n\t\t\trt[i] = 1\n\t\t\tct[j] = 1\ncnt = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\tif rt[i] == 0 or ct[j] == 0:\n\t\t\tcnt += 1\nprint(cnt)\n", "(r, c) = map(int, input().split())\nlist = []\ncnt = 0\nfor k in range(r):\n\tg = input()\n\tlist.append(g)\n\ndef foo_r(x, y):\n\ta = True\n\tif 'S' in list[x]:\n\t\ta = False\n\tb = foo_c(y)\n\tif a == False and b == False:\n\t\treturn False\n\telse:\n\t\treturn True\n\ndef foo_c(z):\n\tn = True\n\tfor f in range(r):\n\t\tif list[f][z] == 'S':\n\t\t\tn = False\n\t\t\tbreak\n\treturn n\nfor i in range(r):\n\tfor j in range(c):\n\t\tif list[i][j] == 'S':\n\t\t\tcontinue\n\t\telse:\n\t\t\tx = foo_r(i, j)\n\t\t\tif x == True:\n\t\t\t\tcnt += 1\nprint(cnt)\n", "(n, m) = list(map(int, input().split()))\nl = []\nr = []\nc = [1 for i in range(m)]\nf = 0\nfor i in range(n):\n\ts = input()\n\tl.append([i for i in s])\n\tif 'S' in s:\n\t\tfor j in range(m):\n\t\t\tif s[j] == 'S':\n\t\t\t\tc[j] = 0\n\t\tf = 1\n\telse:\n\t\tr.append(i)\nif f == 0:\n\tprint(m * n)\nelse:\n\tans = 0\n\tfor i in range(m):\n\t\tif c[i] == 1:\n\t\t\tfor j in range(n):\n\t\t\t\tl[j][i] = '0'\n\t\t\tans += n\n\tfor i in r:\n\t\tfor j in range(m):\n\t\t\tif l[i][j] == '.':\n\t\t\t\tans += 1\n\tprint(ans)\n", "(r, c) = map(int, input().split())\nm = []\na = []\nfor i in range(r):\n\ts = input()\n\ta.append(s)\nfor i in range(r):\n\tif 'S' not in a[i]:\n\t\tm.extend([(i, j) for j in range(c)])\nfor i in range(c):\n\tb = []\n\tfor j in range(r):\n\t\tb.append(a[j][i])\n\tif 'S' not in b:\n\t\tm.extend([(k, i) for k in range(r)])\nm = set(m)\nprint(len(m))\n", "(n, m) = map(int, input().split())\nx = [input() for i in range(n)]\ncnt1 = 0\ncnt2 = 0\nrow = 0\ncol = 0\nfor i in range(n):\n\trow = 0\n\tfor j in range(m):\n\t\tif x[i][j] == 'S':\n\t\t\tbreak\n\t\telse:\n\t\t\trow += 1\n\tif row == m:\n\t\tcnt1 += 1\nfor i in range(m):\n\tcol = 0\n\tfor j in range(n):\n\t\tif x[j][i] == 'S':\n\t\t\tbreak\n\t\telse:\n\t\t\tcol += 1\n\tif col == n:\n\t\tcnt2 += 1\nprint(cnt1 * m + cnt2 * n - cnt1 * cnt2)\n", "(r, c) = map(int, input().split())\nrlist = []\nclist = []\ncake = []\nfor x in range(r):\n\tcake.append(input())\n\tfor y in range(c):\n\t\tif cake[x][y] == 'S':\n\t\t\trlist.append(x)\n\t\t\tclist.append(y)\n(count, cek) = (0, 0)\nfor x in range(r):\n\tif x not in rlist:\n\t\tcount += c\n\t\tcek += 1\nfor x in range(c):\n\tif x not in clist:\n\t\tcount += r\n\t\tcount -= cek\nprint(count)\n", "(r, c) = map(int, input().split(' '))\nboard = []\nfor i in range(r):\n\tboard.append(list(input()))\neaten = 0\nfor i in range(r):\n\tghosts = 0\n\tfor j in range(c):\n\t\tif board[i][j] == 'S':\n\t\t\tghosts += 1\n\tif ghosts == 0:\n\t\tfor j in range(c):\n\t\t\tif board[i][j] == '.':\n\t\t\t\teaten += 1\n\t\t\t\tboard[i][j] = '0'\nfor j in range(c):\n\tghosts = 0\n\tfor i in range(r):\n\t\tif board[i][j] == 'S':\n\t\t\tghosts += 1\n\tif ghosts == 0:\n\t\tfor i in range(r):\n\t\t\tif board[i][j] == '.':\n\t\t\t\teaten += 1\n\t\t\t\tboard[i][j] = '0'\nprint(eaten)\n", "(H, W) = [int(x) for x in input().split()]\nA = []\nateHoris = 0\nateSum = 0\nfor y in range(H):\n\tA.append([])\n\tA[y] = input()\n\tberry = 0\n\tfor x in A[y]:\n\t\tif x == 'S':\n\t\t\tberry = 1\n\tif not berry:\n\t\tateHoris += 1\n\t\tateSum += W\nfor x in range(W):\n\tberry = 0\n\tfor y in range(H):\n\t\tif A[y][x] == 'S':\n\t\t\tberry = 1\n\tif not berry:\n\t\tateSum += H - ateHoris\nprint(ateSum)\n", "(r, c) = map(int, input().split())\n(horiz, vert) = ([], [])\nfor i in range(r):\n\thoriz.append([])\nfor i in range(c):\n\tvert.append([])\nfor i in range(r):\n\ts = input()\n\tfor j in range(c):\n\t\thoriz[i].append(s[j])\n\t\tvert[j].append(s[j])\nans = r * c\nfor i in range(r):\n\tfor j in range(c):\n\t\tif 'S' in horiz[i] and 'S' in vert[j]:\n\t\t\tans -= 1\nprint(ans)\n", "l = list(map(int, input().split()))\nr = l[0]\nc = l[1]\na = 0\nx = 0\nb = 0\ny = 0\nlst = list()\nfor i in range(r):\n\ts = input()\n\tlst.append(s)\nfor i in lst:\n\ta = 0\n\tfor j in i:\n\t\tif j == 'S':\n\t\t\ta = 1\n\t\t\tbreak\n\tif a == 0:\n\t\tx = x + c\nfor i in range(c):\n\tb = 0\n\tfor j in range(r):\n\t\tif lst[j][i] == 'S':\n\t\t\tb = 1\n\t\t\tbreak\n\tif b == 0:\n\t\ty = y + r\nprint(x + y - x * y // (r * c))\n", "(r, c) = map(int, input().split())\ndd = []\nfor i in range(r):\n\ts = input()\n\top = []\n\tfor ii in s:\n\t\top.append(ii)\n\tdd.append(op)\ns1 = 'S'\nr_1 = 0\nfor i in range(r):\n\tif s1 not in dd[i]:\n\t\tr_1 += c\n\t\tfor j in range(c):\n\t\t\tdd[i][j] = -1\nans = []\nop = []\nfor ii in range(c):\n\tc_1 = 0\n\tk = 0\n\tfor jj in range(r):\n\t\tif dd[jj][ii] != s1:\n\t\t\tif dd[jj][ii] == -1:\n\t\t\t\tk += 1\n\t\t\t\tc_1 += 1\n\t\t\telse:\n\t\t\t\tc_1 += 1\n\tif c_1 == r:\n\t\tans.append(c_1)\n\t\top.append(k)\nso = sum(ans)\nko = sum(op)\nprint(so + r_1 - ko)\n", "nums = input().split()\nmainlst = []\npieces = 0\nfor i in range(int(nums[0])):\n\ta = list(input())\n\tmainlst.append(a)\nmainlst2 = []\nfor i in mainlst:\n\tif 'S' not in i:\n\t\tpieces += len(i)\n\telse:\n\t\tmainlst2.append(i)\nnew_lst = list(zip(*mainlst2))\nfor i in new_lst:\n\tif 'S' not in i:\n\t\tpieces += len(i)\nprint(pieces)\n", "(r, c) = map(int, input().split(' '))\nlist1 = []\nfor j in range(r):\n\tlist1.append(list(input()))\nsum1 = 0\nfor j in range(c):\n\tstri = ''\n\tfor i in range(r):\n\t\tstri += list1[i][j]\n\tif 'S' not in stri:\n\t\tsum1 += len(stri)\n\t\tfor i in range(r):\n\t\t\tlist1[i][j] = '*'\nfor j in list1:\n\tif 'S' not in j:\n\t\tsum1 += j.count('.')\nprint(sum1)\n", "(r, c) = [int(i) for i in input().split()]\nstrings = []\nfor _ in range(r):\n\tstrings.append(input())\nrows = [-1 for _ in range(r)]\ncols = [-1 for _ in range(c)]\nfor i in range(r):\n\tfor j in range(c):\n\t\tif strings[i][j] == 'S':\n\t\t\trows[i] = cols[j] = 1\ncount = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\tif rows[i] != 1 or cols[j] != 1:\n\t\t\tcount += 1\nprint(count)\n", "(n, m) = map(int, input().split())\ns = [list(input()) for i in range(n)]\nr1 = len([1 for i in s if 'S' in i])\nr2 = len([1 for i in zip(*s) if 'S' in i])\nprint(n * m - r1 * r2)\n", "(n, m) = map(int, input().split())\ncake = [[i for i in input()] for _ in range(n)]\ncount = 0\nfor i in range(n):\n\tfor j in range(m):\n\t\tif cake[i][j] == '.':\n\t\t\tfor i_mod in range(n):\n\t\t\t\tif cake[i_mod][j] == 'S':\n\t\t\t\t\tS_not_in_column = False\n\t\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tS_not_in_column = True\n\t\t\tif cake[i].count('S') == 0 or S_not_in_column:\n\t\t\t\tcount += 1\nprint(count)\n", "i = input().split()\n(r, c) = (int(i[0]), int(i[1]))\ncake = []\nindex = []\ntotal = 0\nfor i in range(r):\n\trow = input()\n\trow = [x for x in row]\n\tif 'S' not in row:\n\t\tindex.append([0] * c)\n\t\ttotal += c\n\telse:\n\t\tindex.append([1] * c)\n\tcake.append(row)\nfor i in range(c):\n\tfor j in range(r):\n\t\tif cake[j][i] == 'S':\n\t\t\tbreak\n\telse:\n\t\tfor j in range(r):\n\t\t\tif index[j][i] == 1:\n\t\t\t\ttotal += 1\nprint(total)\n", "(r, c) = map(int, input().split())\na = []\no = 0\nfor i in range(r):\n\tb = input()\n\ta.append(b)\n\tif not 'S' in b:\n\t\to += len(a.pop())\n\telse:\n\t\tcontinue\nfor i in range(c):\n\td = 0\n\tfor j in range(len(a)):\n\t\tif a[j][i] == 'S':\n\t\t\td = 0\n\t\t\tbreak\n\t\telse:\n\t\t\td += 1\n\to += d\nprint(o)\n", "(r, c) = map(int, input().split())\nrows = set()\ncol = set()\nfor i in range(r):\n\tx = input()\n\tfor j in range(c):\n\t\tif x[j] == 'S':\n\t\t\trows.add(i)\n\t\t\tcol.add(j)\nprint(r * c - len(rows) * len(col))\n", "(r, c) = map(int, input().split())\nl = []\ns = 0\nfor i in range(r):\n\tl.append(input())\nfor i in range(len(l)):\n\tif l[i].count('S') == 0:\n\t\ts += l[i].count('.')\n\t\tl[i] = ['*' for i in l[i]]\nfor i in range(c):\n\tx = 0\n\tfor j in range(r):\n\t\tif l[j][i] == 'S':\n\t\t\tx = 0\n\t\t\tbreak\n\t\tif l[j][i] == '.':\n\t\t\tx += 1\n\ts += x\nprint(s)\n", "(r, c) = map(int, input().split())\nmapa = []\nlinha = 0\ncoluna = 0\nfor i in range(r):\n\tmapa.append(input())\nfor i in range(r):\n\tif mapa[i].find('S') < 0:\n\t\tlinha += c\nmapa = list(zip(*mapa))\nfor i in range(c):\n\tif ''.join(mapa[i]).find('S') < 0:\n\t\tcoluna += r - linha // c\nprint(linha + coluna)\n", "(r, c) = map(int, input().split())\nl = []\n(re, ce, e) = (0, 0, 0)\nfor i in range(r):\n\tx = input()\n\tif 'S' not in x:\n\t\tre += 1\n\t\te += c\n\tl.append(x)\nfor i in range(c):\n\tf = False\n\tfor j in range(r):\n\t\tif l[j][i] == 'S':\n\t\t\tf = True\n\tif not f:\n\t\tce += 1\n\t\te += r\nprint(e - re * ce)\n", "(n, m) = input().split()\nn = int(n)\nm = int(m)\na = []\ns = []\nfor i in range(n):\n\ts = input()\n\ta.append(s)\nc = 0\nfor i in range(m):\n\tlc = 0\n\tclear = True\n\tfor j in range(n):\n\t\tif a[j][i] == 'S':\n\t\t\tclear = False\n\t\t\tbreak\n\t\telif a[j][i] == '.':\n\t\t\tlc += 1\n\tif clear:\n\t\tt = []\n\t\tfor j in range(n):\n\t\t\ta[j] = a[j][:i] + ' ' + a[j][i + 1:]\n\t\tc += lc\nfor i in range(n):\n\tlc = 0\n\tclear = True\n\tfor j in range(m):\n\t\tif a[i][j] == 'S':\n\t\t\tclear = False\n\t\t\tbreak\n\t\telif a[i][j] == '.':\n\t\t\tlc += 1\n\tif clear:\n\t\ta[i] = m * ' '\n\t\tc += lc\nprint(c)\n", "inp = list(map(int, input().split()))\n(r, c) = inp\narr = []\nfor _ in range(r):\n\ts = input()\n\tarr.append(s)\nfrom collections import Counter\nrow = Counter([])\ncol = Counter([])\nfor i in range(len(arr)):\n\tfor j in range(len(arr[i])):\n\t\tif arr[i][j] == 'S':\n\t\t\trow[i] += 1\n\t\t\tcol[j] += 1\nans = 0\nfor i in range(len(arr)):\n\tfor j in range(len(arr[i])):\n\t\tif row[i] != 0 and col[j] != 0:\n\t\t\tans += 1\nprint(r * c - ans)\n", "a = []\na = input().split()\nr = int(a[0])\nc = int(a[1])\ns = []\nfor i in range(0, r):\n\ts.append(input())\nrow = []\np = 0\nfor i in range(0, r):\n\tcount = 0\n\tfor j in range(0, c):\n\t\tif s[i][j] == '.':\n\t\t\tcount += 1\n\tif count == c:\n\t\tp += c\n\t\trow.append(i)\ncol = []\nfor i in range(0, r):\n\tif row.count(i) == 0:\n\t\tcol.append(s[i])\nfor i in range(0, c):\n\tcount = 0\n\tfor j in range(0, len(col)):\n\t\tif col[j][i] == '.':\n\t\t\tcount += 1\n\tif count == len(col):\n\t\tp += len(col)\nprint(p)\n", "(n, m) = map(int, input().split())\na = []\ncount = 0\nfor i in range(n):\n\ta.append(list(map(str, input().split())))\nfor i in range(n):\n\tif 'S' in a[i][0]:\n\t\tcontinue\n\telse:\n\t\tcount += m\n\t\ta[i][0] = '#' * m\nfor i in range(m):\n\tb = []\n\tfor j in range(n):\n\t\tb.append(a[j][0][i])\n\tif 'S' in b:\n\t\tcontinue\n\telse:\n\t\tcount += b.count('.')\nprint(count)\n", "def cakeMinator(cake):\n\tans = int()\n\tcols = int()\n\tfor i in range(len(cake[0])):\n\t\tfor j in range(len(cake)):\n\t\t\tif cake[j][i] == 'S':\n\t\t\t\tbreak\n\t\telse:\n\t\t\tans += len(cake)\n\t\t\tcols += 1\n\tfor i in range(len(cake)):\n\t\tfor j in range(len(cake[0])):\n\t\t\tif cake[i][j] == 'S':\n\t\t\t\tbreak\n\t\telse:\n\t\t\tans += len(cake[0]) - cols\n\treturn ans\nrc = [int(i) for i in input().split()]\nr = rc[0]\nc = rc[1]\ncake = list()\nfor i in range(r):\n\trow = [i for i in input()]\n\tcake.append(row)\nprint(cakeMinator(cake))\n", "import sys\nfrom functools import reduce\nfrom collections import Counter\nimport time\nimport datetime\nfrom math import sqrt, gcd\n\ndef ip():\n\treturn int(sys.stdin.readline())\n\ndef sip():\n\treturn sys.stdin.readline()\n\ndef mip():\n\treturn map(int, sys.stdin.readline().split())\n\ndef mips():\n\treturn map(str, sys.stdin.readline().split())\n\ndef lip():\n\treturn list(map(int, sys.stdin.readline().split()))\n\ndef matip(n, m):\n\tlst = []\n\tfor i in range(n):\n\t\tarr = lip()\n\t\tlst.append(arr)\n\treturn lst\n\ndef factors(n):\n\treturn list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))\n\ndef minJumps(arr, n):\n\tjumps = [0 for i in range(n)]\n\tif n == 0 or arr[0] == 0:\n\t\treturn float('inf')\n\tjumps[0] = 0\n\tfor i in range(1, n):\n\t\tjumps[i] = float('inf')\n\t\tfor j in range(i):\n\t\t\tif i <= j + arr[j] and jumps[j] != float('inf'):\n\t\t\t\tjumps[i] = min(jumps[i], jumps[j] + 1)\n\t\t\t\tbreak\n\treturn jumps[n - 1]\n\ndef dic(arr):\n\treturn Counter(arr)\n\ndef check_prime(n):\n\tif n < 2:\n\t\treturn False\n\tfor i in range(2, int(n ** 0.5) + 1, 2):\n\t\tif n % i == 0:\n\t\t\treturn False\n\treturn True\n(n, m) = mip()\narr = []\nval = 0\nfor i in range(n):\n\ts = sip()\n\tlst = []\n\tfor j in range(m):\n\t\tlst.append(s[j])\n\tarr.append(lst)\ni = 0\nwhile i < n:\n\tif arr[i].count('S') == 0:\n\t\tval += m\n\t\tarr.pop(i)\n\t\tn -= 1\n\telse:\n\t\ti += 1\nfor i in range(m):\n\tflag = 0\n\tfor j in range(n):\n\t\tif arr[j][i] == 'S':\n\t\t\tflag = 1\n\tif flag == 0:\n\t\tval += n\nprint(val)\n", "import sys\ninf = float('inf')\n(mod, MOD) = (1000000007, 998244353)\n\ndef get_array():\n\treturn list(map(int, sys.stdin.readline().strip().split()))\n\ndef get_ints():\n\treturn map(int, sys.stdin.readline().strip().split())\n\ndef input():\n\treturn sys.stdin.readline().strip()\n(n, m) = get_ints()\nmat = []\nfor i in range(n):\n\tmat.append(list(input()))\nvisited = [[0 for i in range(m)] for j in range(n)]\nfor i in range(n):\n\tfor j in range(m):\n\t\tflag = 0\n\t\tfor k in range(n):\n\t\t\tif mat[k][j] == 'S':\n\t\t\t\tflag = 1\n\t\tif flag == 0:\n\t\t\tfor k in range(n):\n\t\t\t\tvisited[k][j] = 1\n\t\tflag = 0\n\t\tfor k in range(m):\n\t\t\tif mat[i][k] == 'S':\n\t\t\t\tflag = 1\n\t\tif flag == 0:\n\t\t\tfor k in range(m):\n\t\t\t\tvisited[i][k] = 1\nans = 0\nfor i in visited:\n\tans += i.count(1)\nprint(ans)\n", "def R():\n\treturn map(int, input().split())\n\ndef I():\n\treturn int(input())\n\ndef S():\n\treturn str(input())\n\ndef L():\n\treturn list(R())\nfrom collections import Counter\nimport math\nimport sys\nfrom itertools import permutations\nimport bisect\n(n, m) = R()\ns = [''] * n\nfor i in range(n):\n\ts[i] = S()\nr = set()\nc = set()\nfor i in range(n):\n\tfor j in range(m):\n\t\tif s[i][j] == 'S':\n\t\t\tr.add(i)\n\t\t\tc.add(j)\nprint((n - len(r)) * m + (m - len(c)) * n - (n - len(r)) * (m - len(c)))\n", "import sys\ninput = sys.stdin.readline\n\ndef inp():\n\treturn int(input())\n\ndef inlt():\n\treturn list(map(int, input().split()))\n\ndef insr():\n\ts = input()\n\treturn list(s[:len(s) - 1])\n\ndef invr():\n\treturn map(int, input().split())\n\ndef solution(mat, r, c):\n\ttotal = 0\n\tcnt = 0\n\tfor i in range(r):\n\t\tres = 0\n\t\tfor j in range(c):\n\t\t\tif mat[i][j] == 'S':\n\t\t\t\tres = 0\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tres += 1\n\t\ttotal += res\n\t\tif res > 0:\n\t\t\tcnt += 1\n\tdep = 0\n\tfor j in range(c):\n\t\tres = 0\n\t\tfor i in range(r):\n\t\t\tif mat[i][j] == 'S':\n\t\t\t\tres = 0\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tres += 1\n\t\ttotal += res\n\t\tif res > 0:\n\t\t\tdep += 1\n\treturn total - dep * cnt if total >= 0 else 0\n(r, c) = invr()\nmat = []\nfor i in range(r):\n\ts = insr()\n\tmat.append(s)\nprint(solution(mat, r, c))\n", "(r, c) = map(int, input().split())\na = list()\nfor i in range(r):\n\ta.append(input())\nx = 0\nk = 0\nh = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\tif a[i][j] == 'S':\n\t\t\tx = 1\n\t\t\tbreak\n\tif x:\n\t\tx = 0\n\telse:\n\t\tk += c\n\t\th += 1\nx = 0\nfor i in range(c):\n\tfor j in range(r):\n\t\tif a[j][i] == 'S':\n\t\t\tx = 1\n\t\t\tbreak\n\tif x:\n\t\tx = 0\n\telse:\n\t\tk += r - h\nprint(k)\n", "(r, c) = map(int, input().split())\ntort = [input() for i in range(r)]\ncount = 0\ns = 0\nz = 0\ncolumn = []\nq = 0\nfor i in range(r):\n\tif 'S' not in tort[i]:\n\t\tcount += c\n\t\tz += 1\n\telif 'S' in tort[i] and tort[i].count('S') == len(tort[i]):\n\t\ts = 1\nif count == 0 and s == 0 or (count > 0 and s == 1) or (count > 0 and s == 0):\n\tfor i in range(c):\n\t\tfor j in range(r):\n\t\t\tif tort[j][i] == '.':\n\t\t\t\tq += 1\n\t\tcolumn.append(q)\n\t\tq = 0\n\tif count > 0 and max(column) == r:\n\t\tprint(count + max(column) * column.count(max(column)) - column.count(max(column)) * z)\n\telif count == 0 and max(column) == r:\n\t\tprint(max(column) * column.count(max(column)))\n\telse:\n\t\tprint(count)\nelse:\n\tprint(0)\n", "(r, c) = map(int, input().split())\nl = []\nc1 = 0\nx = 0\nfor i in range(r):\n\tl1 = list(input())\n\tif 'S' not in l1:\n\t\tc1 += c\n\t\tx += 1\n\t\tpass\n\telse:\n\t\tl.append(l1)\nr -= x\nfor i in range(c):\n\tc2 = 0\n\tfor j in range(r):\n\t\tif l[j][i] == '.':\n\t\t\tc2 += 1\n\t\telse:\n\t\t\tc2 = 0\n\t\t\tbreak\n\tc1 += c2\nprint(c1)\n", "(r, c) = map(int, input().split())\nl = []\nfor _ in range(r):\n\tl1 = list(input())\n\tl.append(l1)\nto = 0\ne = 0\nfor i in l:\n\tif 'S' not in i:\n\t\tto += c\n\t\te += 1\nfor i in range(c):\n\tno = 0\n\tfor j in range(r):\n\t\tif l[j][i] == 'S':\n\t\t\tno += 1\n\t\t\tbreak\n\tif no == 0:\n\t\tto += r - e\nprint(to)\n", "def inp():\n\treturn map(int, input().split())\n(r, c) = inp()\n(arr, out) = ([], 0)\nfor i in range(r):\n\ts = input()\n\tif s.count('S') != 0:\n\t\tarr.append(s)\n\telse:\n\t\tout += c\nfor i in range(c):\n\tsum = 0\n\tfor j in range(len(arr)):\n\t\tif arr[j][i] != 'S':\n\t\t\tsum += 1\n\t\telse:\n\t\t\tbreak\n\t\tif sum == len(arr):\n\t\t\tout += sum\nprint(out)\n", "(r, c) = list(map(int, input().split()))\ns = 0\nch = [[] for i in range(c)]\nfor i in range(r):\n\tz = input()\n\tif z == c * '.':\n\t\ts += c\n\telse:\n\t\tfor ii in range(c):\n\t\t\tch[ii].append(z[ii])\nfor i in ch:\n\tif i == ['.'] * len(i):\n\t\ts += len(i)\nprint(s)\n", "def solve(r, c, m):\n\tt = 0\n\tfor i in range(r):\n\t\tif m[i].count('.') == c:\n\t\t\tm[i] = 'c' * c\n\t\t\tt += c\n\tfor j in range(c):\n\t\tx = 0\n\t\tfor i in range(r):\n\t\t\tif m[i][j] == '.' or m[i][j] == 'c':\n\t\t\t\tx += 1\n\t\tif x == r:\n\t\t\tfor i in range(r):\n\t\t\t\tif m[i][j] == '.':\n\t\t\t\t\tm[i][j] = 'c'\n\t\t\t\t\tt += 1\n\treturn t\n\ndef main():\n\t(r, c) = list(map(int, input().split()))\n\tm = [list(input()) for _ in range(r)]\n\tprint(solve(r, c, m))\nmain()\n", "(n, k) = [int(x) for x in input().split()]\ntable = []\nfor _ in range(n):\n\ttable.append(list(input()))\nfor i in range(n):\n\tif 'S' not in table[i]:\n\t\ttable[i] = ['e'] * len(table[i])\n\t\tattempt = True\nfor j in range(k):\n\trem = True\n\tfor i in range(n):\n\t\tif table[i][j] == 'S':\n\t\t\trem = False\n\tif rem:\n\t\tfor i in range(n):\n\t\t\ttable[i][j] = 'e'\nprint(''.join([''.join(x) for x in table]).count('e'))\n", "num = input()\na = []\n\ndef get_the_data(count, num, arr):\n\tfor i in range(0, len(num)):\n\t\tif num[i] == ' ':\n\t\t\tarr.append(int(num[count:i]))\n\t\t\tcount = i + 1\n\t\telif i == len(num) - 1:\n\t\t\tarr.append(int(num[count:len(num)]))\n\treturn arr\narr = get_the_data(0, num, a)\nn = a[0]\ni = 0\ndata = list()\nwhile i < n:\n\tdata.append(input())\n\ti += 1\nmix = [[False] * len(data[0]) for _ in range(len(data))]\ncount = 0\nfor i in range(0, len(data)):\n\tcheck = False\n\tfor j in range(0, len(data[i])):\n\t\tif data[i][j] == 'S':\n\t\t\tcheck = True\n\t\t\tbreak\n\tif check == False:\n\t\tfor j in range(0, len(data[i])):\n\t\t\tmix[i][j] = True\n\t\tcount += len(data[i])\nfor i in range(len(data[0])):\n\tcheck = False\n\tfor j in data:\n\t\tif j[i] == 'S':\n\t\t\tcheck = True\n\t\t\tbreak\n\tif check == False:\n\t\tfor j in range(len(data)):\n\t\t\tif mix[j][i] == False:\n\t\t\t\tcount += 1\nprint(count)\n", "(n, m) = map(int, input().split())\nb = [list((i for i in input())) for j in range(n)]\nsay = 0\nfor i in range(n):\n\tif 'S' not in b[i]:\n\t\tfor j in range(m):\n\t\t\tif b[i][j] == '.':\n\t\t\t\tsay += 1\n\t\t\t\tb[i][j] = ','\nd = []\nfor i in range(m):\n\ta = []\n\tfor j in range(n):\n\t\ta.append(b[j][i])\n\td.append(a)\nfor i in range(m):\n\tif 'S' not in d[i]:\n\t\tfor j in range(n):\n\t\t\tif d[i][j] == '.':\n\t\t\t\tsay += 1\n\t\t\t\td[i][j] = ','\nprint(say)\n", "(n, m) = map(int, input().split())\na = []\nfor i in range(n):\n\ta.append(list(input()))\nfor i in range(n):\n\tok = 1\n\tfor j in range(m):\n\t\tif a[i][j] == 'S':\n\t\t\tok = 0\n\tif ok:\n\t\tfor j in range(m):\n\t\t\ta[i][j] = '+'\nfor j in range(m):\n\tok = 1\n\tfor i in range(n):\n\t\tif a[i][j] == 'S':\n\t\t\tok = 0\n\tif ok:\n\t\tfor i in range(n):\n\t\t\ta[i][j] = '+'\no = 0\nfor i in range(n):\n\tfor j in range(m):\n\t\tif a[i][j] == '+':\n\t\t\to += 1\nprint(o)\n", "import math\nfrom collections import defaultdict, Counter, deque\nINF = float('inf')\n\ndef gcd(a, b):\n\twhile b:\n\t\t(a, b) = (b, a % b)\n\treturn a\n\ndef primeFactor(n):\n\tif n % 2 == 0:\n\t\treturn 2\n\ti = 3\n\twhile i ** 2 <= n:\n\t\tif n % i == 0:\n\t\t\treturn i\n\t\ti += 1\n\treturn n\n\ndef main():\n\t(n, m) = map(int, input().split())\n\tmat = []\n\tfor i in range(n):\n\t\tmat.append(input())\n\tans = 0\n\te = defaultdict(int)\n\tfor i in range(n):\n\t\teaten = 0\n\t\tif 'S' not in mat[i]:\n\t\t\tfor j in range(m):\n\t\t\t\te[i, j] = 1\n\t\t\t\teaten += 1\n\t\t\tans += eaten\n\tfor j in range(m):\n\t\teaten = 0\n\t\tisS = False\n\t\tfor i in range(n):\n\t\t\tif mat[i][j] == 'S':\n\t\t\t\tisS = True\n\t\t\t\tbreak\n\t\tif not isS:\n\t\t\tfor i in range(n):\n\t\t\t\tif e[i, j] == 0:\n\t\t\t\t\te[i] = 1\n\t\t\t\t\teaten += 1\n\t\t\tans += eaten\n\tprint(ans)\nt = 1\nfor _ in range(t):\n\tmain()\n", "(r, c) = map(int, input().split())\nx = set()\ny = set()\nfor i in range(r):\n\tt = [k for k in list(input())]\n\tfor j in range(c):\n\t\tif t[j] == 'S':\n\t\t\tx.add(j)\n\t\t\ty.add(i)\nprint(r * c - len(x) * len(y))\n", "(n, m) = map(int, input().split())\nc = 0\na = []\nfor i in range(n):\n\ts = input()\n\tif s.count('.') == m:\n\t\tc = c + 1\n\ta.append(s)\nr = 0\nfor i in range(m):\n\ty = ''\n\tfor j in range(n):\n\t\ty = y + a[j][i]\n\tif y.count('.') == n:\n\t\tr = r + 1\nprint(c * m + r * n - c * r)\n", "(n, m) = [int(i) for i in input().split()]\ncake = []\neatenBlocks = 0\neatenRows = 0\nfor k in range(0, n):\n\tcake.append(input())\n\tif 'S' not in cake[k]:\n\t\teatenBlocks += m\n\t\teatenRows += 1\nfor j in range(0, m):\n\tcanEat = False\n\tfor i in range(0, n):\n\t\tif cake[i][j] != 'S':\n\t\t\tcanEat = True\n\t\telse:\n\t\t\tcanEat = False\n\t\t\tbreak\n\tif canEat == True:\n\t\teatenBlocks += n - eatenRows\n\t\tcanEat = False\nprint(eatenBlocks)\n", "(n, m) = map(int, input().split())\nb = []\nfor t in range(n):\n\ta = input()\n\ts = [char for char in a]\n\tb.append(s)\ni = 0\nj = 0\nwhile i < n:\n\twhile j < m:\n\t\tif b[i][j] == 'S':\n\t\t\tbreak\n\t\tif j + 1 == m:\n\t\t\tj = 0\n\t\t\twhile j < m:\n\t\t\t\tb[i][j] = 'X'\n\t\t\t\tj += 1\n\t\tj += 1\n\tj = 0\n\ti += 1\ni = 0\nj = 0\nwhile j < m:\n\twhile i < n:\n\t\tif b[i][j] == 'S':\n\t\t\tbreak\n\t\tif i + 1 == n:\n\t\t\ti = 0\n\t\t\twhile i < n:\n\t\t\t\tb[i][j] = 'X'\n\t\t\t\ti += 1\n\t\ti += 1\n\ti = 0\n\tj += 1\ntotal = 0\nfor c in range(len(b)):\n\tfor l in range(len(b[c])):\n\t\tif b[c][l] == 'X':\n\t\t\ttotal += 1\nprint(total)\n", "(r, c) = (int(i) for i in input().split())\ncols = set()\nrows = 0\nfor i in range(r):\n\ts = list(input())\n\tif 'S' in s:\n\t\trows += 1\n\t\twhile 'S' in s:\n\t\t\tcols.add(s.index('S') + 1)\n\t\t\ts[s.index('S')] = '.'\nprint(r * c - rows * len(cols))\n", "(n, m) = map(int, input().split())\na = []\nc = 0\nfor i in range(n):\n\ts = input()\n\ts = s.replace('S', '0')\n\ts = s.replace('.', '1')\n\tb = list(s)\n\ta.append(b)\n\tif s.count('1') == m:\n\t\tc += 1\ncount = c * m\nfor i in range(m):\n\tz = 0\n\tfor j in range(n):\n\t\tif a[j][i] == '1':\n\t\t\tz += 1\n\t\telse:\n\t\t\tz = 0\n\t\t\tbreak\n\tif z != 0:\n\t\tcount += z - c\nprint(count)\n", "num = input()\nnums = num.split()\nnum_row = int(nums[0])\nnum_col = int(nums[1])\nrows_evil = {}\ncols_evil = {}\nnum_evil = 0\nfor i in range(0, num_row):\n\trow = input()\n\tfor k in range(0, len(row)):\n\t\tif row[k] == 'S':\n\t\t\tcols_evil[k] = 1\n\t\t\trows_evil[i] = 1\ncake = (num_row - len(rows_evil)) * num_col\ncake += (num_col - len(cols_evil)) * len(rows_evil)\nprint(cake)\n", "(r, c) = map(int, input().split())\ns = set()\ncood = []\nvirtuel = set()\nfor i in range(r):\n\tl = input()\n\tfor j in range(c):\n\t\tif l[j] == 'S':\n\t\t\ts.add((i + 1, j + 1))\n\t\t\tcood.append(j + 1)\nfor element in s:\n\tfor co in cood:\n\t\tvirtuel.add((element[0], co))\nprint(r * c - len(s | virtuel))\n", "(r, c) = map(int, input().split())\nl = [input() for _ in range(r)]\n(count, share) = (0, 0)\ntemp = []\nfor i in l:\n\tif '.' * c in i:\n\t\tcount += 1 * c\n\t\tshare += 1\nfor j in range(c):\n\ttemp = []\n\tfor i in range(r):\n\t\tif l[i][j] == 'S':\n\t\t\ttemp = []\n\t\t\tbreak\n\t\telse:\n\t\t\ttemp.append(l[i][j])\n\tif temp:\n\t\tcount += 1 * r - share\nprint(count)\n", "(n, m) = map(int, input().split())\na = ['' for i in range(m)]\ncnt = 0\nfor i in range(n):\n\ts = input()\n\tif 'S' not in s:\n\t\tcnt += m\n\t\ts = '*' * m\n\tfor j in range(m):\n\t\ta[j] += s[j]\nfor i in range(m):\n\ts = a[i]\n\tif 'S' not in s:\n\t\tb = s.count('.')\n\t\tcnt += b\nprint(cnt)\n", "(r, c) = map(int, input().split())\n(L1, L2) = ([0] * r, [0] * c)\nfor i in range(r):\n\ts = input()\n\tfor j in range(c):\n\t\tif s[j] == 'S':\n\t\t\tL1[i] += 1\n\t\t\tL2[j] += 1\nprint(L1.count(0) * c + L2.count(0) * (r - L1.count(0)))\n", "z = list(map(int, input().split()))\nn = z[0]\nm = z[1]\narr = []\nfor i in range(n):\n\tarr += [[' '] * m]\n\tx = input()\n\tfor j in range(m):\n\t\tarr[i][j] = x[j]\ncount = 0\nstatus = 0\nfor i in range(n):\n\tfor j in range(m):\n\t\tif arr[i][j] == '.' or arr[i][j] == ',':\n\t\t\tif arr[i][j] == '.':\n\t\t\t\tstatus += 1\n\t\telse:\n\t\t\tstatus = 0\n\t\t\tbreak\n\tif status != 0:\n\t\tcount += status\n\t\tstatus = 0\n\t\tfor j in range(m):\n\t\t\tarr[i][j] = ','\nstatus = 0\nfor i in range(m):\n\tfor j in range(n):\n\t\tif arr[j][i] == '.' or arr[j][i] == ',':\n\t\t\tif arr[j][i] == '.':\n\t\t\t\tstatus += 1\n\t\telse:\n\t\t\tstatus = 0\n\t\t\tbreak\n\tif status != 0:\n\t\tcount += status\n\t\tstatus = 0\n\t\tfor j in range(n):\n\t\t\tarr[j][i] == ','\nprint(count)\n", "(r, c) = map(int, input().split())\n(nr, nc) = ([], [])\nfor x in range(r):\n\tn = list(input())\n\tif 'S' in n:\n\t\ti = [j for (j, k) in enumerate(n) if k == 'S']\n\t\tnr.append(x)\n\t\tfor z in i:\n\t\t\tnc.append(z)\n(a, b) = (len(set(nr)), len(set(nc)))\nprint((r - a) * c + (c - b) * r - (r - a) * (c - b))\n", "def count(arr, rows, columns, r, c):\n\tfor row in range(r):\n\t\tif row not in rows:\n\t\t\tarr[row] = ['e'] * c\n\tfor col in range(c):\n\t\tif col not in columns:\n\t\t\tfor row in range(r):\n\t\t\t\tarr[row][col] = 'e'\n\treturn arr\narr = list(map(int, input().rstrip().split()))\nr = arr[0]\nc = arr[1]\narr = []\nrows = []\ncolumns = []\nfor i in range(r):\n\ttemp = list(input().rstrip())\n\tarr.append(temp)\n\tif 'S' in temp:\n\t\trows.append(i)\n\t\tindex = temp.index('S')\n\t\twhile True:\n\t\t\tcolumns.append(index)\n\t\t\ttemp = arr[i][index + 1:]\n\t\t\tif 'S' not in temp:\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tindex += temp.index('S') + 1\ntotal = 0\narr = count(arr, rows, columns, r, c)\nfor i in range(r):\n\tfor j in range(c):\n\t\tif arr[i][j] == 'e':\n\t\t\ttotal += 1\nprint(total)\n", "(n, m) = map(int, input().split())\ncountern = [0] * n\ncounterm = [0] * m\nfor i in range(n):\n\tx = input()\n\tfor j in range(m):\n\t\tif x[j] == 'S':\n\t\t\tcountern[i] = 1\n\t\t\tcounterm[j] = 1\nsumn = 0\nfor i in range(n):\n\tsumn += countern[i]\nsumm = 0\nfor i in range(m):\n\tsumm += counterm[i]\nprint(n * m - sumn * summ)\n", "(r, c) = map(int, input().split())\nh = []\nv = []\nfor i in range(r):\n\tx = list(input())\n\tfor j in range(c):\n\t\tif x[j] == 'S':\n\t\t\th.append(i)\n\t\t\tv.append(j)\nans = r * c - len(list(set(h))) * len(list(set(v)))\nprint(ans)\n", "(r, c) = map(int, input().split())\ncake = []\nfor i in range(r):\n\tcake.append(list(input()))\ni = 0\ncount = 0\nwhile i < r:\n\tif not 'S' in cake[i]:\n\t\tr -= 1\n\t\tcount += c\n\t\tdel cake[i]\n\telse:\n\t\ti += 1\nfor x in range(c):\n\tcol = [cake[z][x] for z in range(r)]\n\tif not 'S' in col:\n\t\tcount += r\nprint(count)\n", "(r, c) = map(int, input().split())\nx = 0\ny = []\nfor i in range(r):\n\ts = input()\n\tif 'S' in s:\n\t\tx += 1\n\tfor j in range(len(s)):\n\t\tif 'S' == s[j] and j not in y:\n\t\t\ty.append(j)\nprint(r * c - x * len(y))\n", "(r, c) = [int(x) for x in input().split()]\ncake = []\nfor i in range(0, r):\n\tcake.append(input())\nnumber = 0\nnotrows = 0\nfor row in cake:\n\tif 'S' not in row:\n\t\tnumber += c\n\t\tnotrows += 1\nfor column in range(0, c):\n\tfind = False\n\tfor row in cake:\n\t\tif row[column] == 'S':\n\t\t\tfind = True\n\tif not find:\n\t\tnumber += r - notrows\nprint(number)\n", "(r, c) = map(int, input().split())\nb = [r for i in range(c)]\n(count, x) = (0, 0)\nfor i in range(r):\n\ta = input()\n\tif 'S' not in a:\n\t\tcount += c\n\t\tx += 1\n\telse:\n\t\tfor j in range(c):\n\t\t\tif a[j] == 'S':\n\t\t\t\tb[j] -= 1\nfor i in b:\n\tif i == r:\n\t\tcount = count + i - x\nprint(count)\n", "(r, c) = map(int, input().split())\n(row, col) = (set(), set())\nfor i in range(r):\n\ta = input()\n\tfor j in range(c):\n\t\tif a[j] == 'S':\n\t\t\trow.add(i)\n\t\t\tcol.add(j)\nn = r - len(row)\nm = c - len(col)\nprint(n * c + m * r - n * m)\n", "(m, n) = [int(x) for x in input().split()]\nrow = 0\narr = []\nfor i in range(m):\n\tx = input()\n\tif x.count('S') == 0:\n\t\trow += 1\n\telse:\n\t\tfor j in range(n):\n\t\t\tif x[j] == 'S':\n\t\t\t\tarr.append(j)\ncol = n - len(set(arr))\nprint(row * n + col * m - row * col)\n", "(r, c) = [int(i) for i in input().split()]\nmatrix = []\nres = 0\nfor _ in range(r):\n\tmatrix.append(input())\nfor i in range(r - 1, -1, -1):\n\tif 'S' in list(matrix[i]):\n\t\tcontinue\n\telse:\n\t\tres += len(matrix[i])\n\t\tdel matrix[i]\nfor tup in zip(*matrix):\n\tif 'S' in tup:\n\t\tcontinue\n\telse:\n\t\tres += len(tup)\nprint(res)\n", "a = [int(i) for i in filter(None, input().split(' '))]\narr = []\nfor i in range(a[0]):\n\tarr += [i for i in filter(None, input().split(' '))]\nstolb = []\nstr = []\nfor i in range(a[0]):\n\tfor j in range(a[1]):\n\t\tif arr[i][j] == 'S':\n\t\t\tif not i in str:\n\t\t\t\tstr.append(i)\n\t\t\tif not j in stolb:\n\t\t\t\tstolb.append(j)\nk_str = len(str)\nk_stolb = len(stolb)\nans = a[0] * a[1] - k_stolb * k_str\nprint(ans)\n", "(a, b) = map(int, input().split())\nl = []\nk = 0\nfor i in range(a):\n\tl.append(input())\nfor i in range(a):\n\tif l[i].count('S') == 0:\n\t\tk += b\n\t\tl[i] = '*' * b\nfor i in range(b):\n\tv = 0\n\to = 0\n\tfor j in range(a):\n\t\tif l[j][i] == '.':\n\t\t\tv += 1\n\t\telif l[j][i] == '*':\n\t\t\to += 1\n\tif v + o == a:\n\t\tk += v\nprint(k)\n", "n = input().split(' ')\ncake = []\ncount = 0\nfor i in range(int(n[0])):\n\trow = list(input())\n\tcake.append(row)\nfor i in cake:\n\tif 'S' not in i:\n\t\tcount += len(i)\n\t\tfor j in range(len(i)):\n\t\t\ti[j] = 0\nberry = False\nfor j in range(len(cake[0])):\n\tfor k in range(len(cake)):\n\t\tif cake[k][j] == 'S':\n\t\t\tberry = True\n\t\t\tbreak\n\tif not berry:\n\t\tfor k in range(len(cake)):\n\t\t\tif cake[k][j] == '.':\n\t\t\t\tcount += 1\n\tberry = False\nprint(count)\n", "(r, c) = map(int, input().split())\ncount = 0\nrows = set()\ncols = set()\nfor i in range(r):\n\ts = input().strip()\n\tfor j in range(c):\n\t\tif s[j] == 'S':\n\t\t\tcols.add(j)\n\t\t\trows.add(i)\nprint(r * c - len(rows) * len(cols))\n", "(r, c) = map(int, input().split())\na = [input() for i in range(r)]\nrow_count = 0\ncolumn_count = 0\nfor i in a:\n\tif 'S' not in i:\n\t\trow_count += 1\nb = []\nfor j in range(c):\n\tt = ''\n\tfor i in range(r):\n\t\tt += a[i][j]\n\tb.append(t)\nfor i in b:\n\tif 'S' not in i:\n\t\tcolumn_count += 1\nprint(r * column_count + c * row_count - row_count * column_count)\n", "(r, c) = map(int, input().split())\na = []\nans = 0\ncounter = r\ns = input()\nif s.find('S') == -1:\n\tans += c\n\tcounter -= 1\n\ta = [i for i in range(c)]\nelse:\n\tfor j in range(c):\n\t\tif s[j] != 'S':\n\t\t\ta.append(j)\nfor i in range(r - 1):\n\ts = input()\n\tif s.find('S') == -1:\n\t\tans += c\n\t\tcounter -= 1\n\telse:\n\t\tfor i in range(len(a)):\n\t\t\tif s[a[i]] == 'S':\n\t\t\t\ta[i] = -1\nfor i in range(len(a)):\n\tif a[i] != -1:\n\t\tans += counter\nprint(ans)\n", "(m, n) = list(map(int, input().split(' ')))\ninputList = []\nstrawberryPosRow = []\nstrawberryPosCol = []\nfor row in range(m):\n\tch = input()\n\tinputList.append(ch)\nfor i in range(len(inputList)):\n\tfor j in range(n):\n\t\tif inputList[i][j] == 'S':\n\t\t\tstrawberryPosRow.append(i)\n\t\t\tstrawberryPosCol.append(j)\nr = len(set(strawberryPosRow))\nc = len(set(strawberryPosCol))\nprint(m * n - r * c)\n", "(r, c) = list(map(int, input().split()))\nno_r = 0\na = []\nres = 0\nfor _ in range(r):\n\ts = input()\n\ta.append(s)\n\tif 'S' not in s:\n\t\tno_r += 1\nfor i in range(c):\n\thas_s = False\n\tfor j in range(r):\n\t\tif a[j][i] == 'S':\n\t\t\thas_s = True\n\t\t\tbreak\n\tif not has_s:\n\t\tres += r - no_r\nres += no_r * c\nprint(res)\n", "(r, c) = map(int, input().split())\nl = []\nfor _ in range(r):\n\ts = input()\n\tl.append(s)\na = []\nb = []\nz = 0\nfor x in range(r):\n\tfor y in range(c):\n\t\tif l[x][y] == 'S':\n\t\t\ta.append(x)\n\t\t\tb.append(y)\nfor i in range(r):\n\tfor j in range(c):\n\t\tif i in a and j in b:\n\t\t\tz += 0\n\t\telse:\n\t\t\tz += 1\nprint(z)\n", "(r, c) = map(int, input().split())\na = []\nrapple = 0\ncapple = 0\nfor i in range(r):\n\tn = input()\n\tif 'S' in n:\n\t\trapple += 1\n\ta.append(list(n))\nfor i in range(c):\n\tfor j in range(r):\n\t\tif a[j][i] == 'S':\n\t\t\tcapple += 1\n\t\t\tbreak\nans = r * c - rapple * capple\nif ans >= 0:\n\tprint(ans)\nelse:\n\tprint(0)\n", "(r, c) = [int(z) for z in input().split()]\nr1 = list(range(0, r))\nc1 = list(range(0, c))\nfor i in range(0, r):\n\ts = input()\n\tfor j in range(0, len(s)):\n\t\tif s[j] == 'S':\n\t\t\tif i in r1:\n\t\t\t\tr1.remove(i)\n\t\t\tif j in c1:\n\t\t\t\tc1.remove(j)\nprint(len(r1) * c + len(c1) * r - len(r1) * len(c1))\n", "(n, m) = map(int, input().split())\nfull = [0] * n\ncount = add = 0\nfor i in range(n):\n\tfull[i] = '-'.join(input()).split('-')\n\tfor j in range(m):\n\t\tif full[i][j] == 'S':\n\t\t\tfull[i][j] = 2\n\t\telse:\n\t\t\tfull[i][j] = 1\nfor i in range(n):\n\tif full[i].count(2) > 0:\n\t\tcontinue\n\telse:\n\t\tfor j in range(m):\n\t\t\tif full[i][j] == 1:\n\t\t\t\tfull[i][j] = 0\n\t\t\t\tcount += 1\nfor i in range(m):\n\tfor j in range(n):\n\t\tbackup = full[j][i]\n\t\tfull[j][i] = '+'\n\t\tfull[j][i] = backup\n\t\tif full[j][i] == 2:\n\t\t\tadd = 0\n\t\t\tbreak\n\t\tif j == n - 1:\n\t\t\tfor j in range(n):\n\t\t\t\tbackup = full[j][i]\n\t\t\t\tfull[j][i] = '+'\n\t\t\t\tfull[j][i] = backup\n\t\t\t\tif full[j][i] == 1:\n\t\t\t\t\tfull[j][i] = 0\n\t\t\t\t\tcount += 1\nprint(count)\n", "(r, c) = map(int, input().split())\n(S_rows, S_columns) = (set(), set())\nfor i in range(r):\n\tfor (j, cell) in enumerate(input()):\n\t\tif cell == 'S':\n\t\t\tS_rows.add(i)\n\t\t\tS_columns.add(j)\nprint(r * c - len(S_rows) * len(S_columns))\n", "(r, c) = map(int, input().split())\nco = 0\nlis = []\nfor i in range(r):\n\tst = input()\n\tfor i in range(c):\n\t\tif st[i] == 'S':\n\t\t\tlis.append(i)\n\tfor i in range(c):\n\t\tif st[i] == 'S':\n\t\t\tco += 1\n\t\t\tbreak\nif len(lis) > 0:\n\tlis = set(lis)\nprint(r * c - len(lis) * co)\n", "(x, y) = map(int, input().split())\na = []\nb = ['.' for i in range(y)]\np = 0\nq = 0\nfor i in range(x):\n\ta.append(input())\nfor i in range(y):\n\tfor t in range(x):\n\t\tb[i] = b[i] + a[t][i]\nfor i in range(x):\n\tif a[i].count('S') == 0:\n\t\tp = p + y\nif p > 0:\n\tx = x - p // y\nfor i in range(y):\n\tif b[i].count('S') == 0:\n\t\tq = q + x\nprint(p + q)\n", "(n, m) = map(int, input().split())\ncount1 = 0\nl = []\nfor i in range(n):\n\ts = input()\n\tif 'S' not in s:\n\t\tcount1 += m\n\telse:\n\t\tl.append(s)\nfor j in range(m):\n\tcount2 = 0\n\tfor x in range(len(l)):\n\t\tif l[x][j] != 'S':\n\t\t\tcount2 += 1\n\t\telse:\n\t\t\tcount2 = 0\n\t\t\tbreak\n\tcount1 += count2\nprint(count1)\n", "(r, c) = map(int, input('').split())\nl = list()\nsumm = 0\nfor i in range(r):\n\tl.append(input())\n\tif 'S' not in l[i]:\n\t\tsumm += 1\nflag = False\nsumhor = 0\nfor i in range(c):\n\tfor j in range(r):\n\t\tif l[j][i] == 'S':\n\t\t\tflag = True\n\t\t\tbreak\n\tif flag == False:\n\t\tsumhor += 1\n\tflag = False\nprint(summ * c + (sumhor * r - summ * sumhor))\n", "(r, c) = [int(i) for i in input().split()]\narr = []\nk = 0\nr2 = r\nfor i in range(r):\n\ta = input()\n\tarr.append(list(a))\nfor i in range(r):\n\tif 'S' not in arr[i]:\n\t\tk += c\n\t\tr2 -= 1\nfor j in range(c):\n\tfor i in range(r):\n\t\tif 'S' == arr[i][j]:\n\t\t\tbreak\n\telse:\n\t\tk += r2\nprint(k)\n", "(r, c) = map(int, input().strip().split(' '))\narr = [[j for j in input().strip()] for i in range(r)]\n(count1, count2) = (0, 0)\nfor i in range(r):\n\tif arr[i] == ['.'] * c:\n\t\tcount1 += 1\nfor j in range(c):\n\t(i, a) = (0, [])\n\twhile i < r:\n\t\tif arr[i][j] == '.':\n\t\t\ta.append('.')\n\t\ti += 1\n\tif len(a) == r:\n\t\tcount2 += 1\nprint(c * count1 + r * count2 - count1 * count2)\n", "(r, c) = map(int, input().split())\na = [input() for i in range(r)]\ncount = 0\nfor x in range(r):\n\tif 'S' not in a[x]:\n\t\ta[x] = 'I' * c\n\t\tcount += c\nfor y in range(c):\n\tvar = 0\n\tfor x in range(r):\n\t\tif a[x][y] == '.':\n\t\t\tvar += 1\n\t\telif a[x][y] == 'S':\n\t\t\tvar = 0\n\t\t\tbreak\n\tcount += var\nprint(count)\n", "(r, c) = map(int, input().split())\nn = [0] * r\nm = [0] * c\nd = r * c\nfor i in range(r):\n\tl = list(map(str, input()))\n\tfor j in range(c):\n\t\tif l[j] == 'S':\n\t\t\tn[i] = 1\n\t\t\tm[j] = 1\nfor i in range(r):\n\tfor j in range(c):\n\t\tif n[i] == 1 and m[j] == 1:\n\t\t\td = d - 1\nprint(d)\n", "(m, n) = map(int, input().split())\nmat = []\ncount = 0\nc = 0\nsx = 0\nc2 = 0\ncount2 = 0\nfor i in range(m):\n\tmat.append(input())\nfor i2 in mat:\n\tcount2 += i2.count('.' * n)\nfor j in range(n):\n\tfor j2 in range(m):\n\t\tif mat[j2][j] == '.':\n\t\t\tc = 1\n\t\telse:\n\t\t\tc = 0\n\t\tsx = sx + c\n\t\tif j2 == m - 1:\n\t\t\tc2 = sx\n\t\t\tsx = 0\n\t\tif c2 == m:\n\t\t\tcount += 1\n\t\t\tc2 = 0\nprint(count2 * n - count * count2 + count * m)\n", "(rows, cols) = map(int, input().split())\nr = [0] * rows\nc = [0] * cols\nrcount = ccount = 0\nfor i in range(rows):\n\ts = input()\n\tfor j in range(cols):\n\t\tif s[j] == 'S':\n\t\t\tr[i] = c[j] = 1\nfor i in range(rows):\n\tif not r[i]:\n\t\trcount += 1\nfor i in range(cols):\n\tif not c[i]:\n\t\tccount += 1\nresult = cols * rcount + rows * ccount - rcount * ccount\nprint(result)\n", "a = list(map(int, input().split()))\nb = []\nfor i in range(a[0]):\n\tb += [input()]\nc = 0\nd = 0\nfor i in range(a[0]):\n\tif b[i].count('S') != 0:\n\t\tc += 1\nfor i in range(a[1]):\n\tif [j[i] for j in b].count('S') != 0:\n\t\td += 1\nprint(a[0] * a[1] - c * d)\n", "(r, c) = map(int, input().split())\nk = 0\nl = []\nm = 0\nfor i in range(r):\n\ts = input()\n\tl.append(s)\n\tif s.count('S') == 0:\n\t\tk += 1\nfor i in range(c):\n\ttest = True\n\tfor j in range(r):\n\t\tif l[j][i] == 'S':\n\t\t\ttest = False\n\tif test:\n\t\tm += 1\nprint(c * k + r * m - m * k)\n", "(r, c) = map(int, input().split())\nl = []\nar = []\nfor i in range(r):\n\ts = input()\n\tarr = []\n\tfor i in s:\n\t\tarr.append(i)\n\tl.append(arr)\nfor j in range(c):\n\ta = []\n\tfor i in range(r):\n\t\ta.append(l[i][j])\n\tar.append(a)\ns = set()\nfor i in range(r):\n\tif 'S' not in l[i]:\n\t\tfor j in range(c):\n\t\t\ts.add((i, j))\nfor i in range(c):\n\tif 'S' not in ar[i]:\n\t\tfor j in range(r):\n\t\t\ts.add((j, i))\nprint(len(s))\n", "(n, m) = map(int, input().split())\na = []\nb = []\n(x, y) = (0, 0)\nfor i in range(n):\n\ta.append(list(input()))\nfor i in range(m):\n\tb.append(['.'] * n)\nfor i in range(n):\n\tfor j in range(m):\n\t\tif not 'S' in a[i][0:m + 1]:\n\t\t\tx += 1\n\t\tbreak\nfor i in range(m):\n\tfor j in range(n):\n\t\tb[i][j] = a[n - 1 - j][i]\nfor i in range(m):\n\tfor j in range(n):\n\t\tif not 'S' in b[i][0:n + 1]:\n\t\t\ty += 1\n\t\tbreak\nprint(x * m + y * n - x * y)\n", "from sys import stdin, stdout\nnm = list(map(int, stdin.readline().split()))\nn = nm[0]\nm = nm[1]\ncount = 0\ncake = []\nfor i in range(n):\n\trow = stdin.readline().strip()\n\tif 'S' not in row:\n\t\tcount += m\n\telse:\n\t\tcake.append(row)\nfor cell in range(m):\n\tcol = ''\n\tfor i in cake:\n\t\tcol += i[cell]\n\tif 'S' not in col:\n\t\tcount += len(col)\nstdout.write(str(count))\n", "(r, c) = map(int, input().split())\ns = [input() for _ in range(r)]\ns = [t if t.count('S') != 0 else 't' * c for t in s]\nk = c * sum([t[0] == 't' for t in s])\nfor j in range(c):\n\tif all([s[i][j] != 'S' for i in range(r)]):\n\t\tk += sum([s[i][j] != 't' for i in range(r)])\nprint(k)\n", "(n, m) = [int(i) for i in input().split()]\nmat = []\nfor i in range(n):\n\ts = str(input())\n\ta = list(s)\n\tmat.append(a)\nline = 0\nans = 0\nlines = 0\nfor i in range(0, len(mat)):\n\te = ''\n\tfor j in range(0, len(mat[i])):\n\t\te = e + mat[i][j]\n\tif e.count('.') == len(e):\n\t\tline = line + 1\n\t\tans = ans + len(e)\nfor i in range(0, m):\n\te = ''\n\tfor j in range(0, len(mat)):\n\t\te = e + mat[j][i]\n\tif e.count('.') == len(e):\n\t\tlines = lines + 1\n\t\tans = ans + len(e)\nprint(ans - line * lines)\n", "(row, column) = map(int, input().split())\ncr = 0\ncc = 0\ntable = []\nfor _ in range(row):\n\ttable.append(input())\ncr = table.count('.' * column)\nfor j in range(column):\n\tcheck = True\n\tfor i in range(row):\n\t\tif table[i][j] == 'S':\n\t\t\tcheck = False\n\t\t\tbreak\n\tif check:\n\t\tcc += 1\nprint(cr * column + cc * row - cc * cr)\n", "(r, c) = [int(f) for f in input().split()]\nx = 0\ny = 0\ncake = []\nfor i in range(r):\n\tb = input()\n\tcake.append(b)\n\tif 'S' not in b:\n\t\tx += 1\nfor f in range(c):\n\tfor i in range(r):\n\t\tif cake[i][f] == 'S':\n\t\t\tbreak\n\telse:\n\t\ty += r - x\nprint(x * c + y)\n", "(r, c) = map(int, input().split())\nx = r * [0]\ny = c * [0]\ncount = 0\nfor i in range(r):\n\ts = input()\n\tfor j in range(c):\n\t\tif s[j] == 'S':\n\t\t\tx[i] = 1\n\t\t\ty[j] = 1\na = x.count(1)\nb = y.count(1)\nprint(r * c - a * b)\n", "(r, c) = map(int, input().split())\ntable1 = list()\ntable2 = list()\nsum = 0\ncounter = 0\nfor i in range(r):\n\ttable1.append(input())\nfor i in range(c):\n\tstr = ''\n\tfor j in range(r):\n\t\tstr += table1[j][i]\n\ttable2.append(str)\nfor i in range(r):\n\tif 'S' in table1[i]:\n\t\tcontinue\n\telse:\n\t\tsum += c\n\t\tcounter += 1\nfor i in range(c):\n\tif 'S' in table2[i]:\n\t\tcontinue\n\telse:\n\t\tsum += r - counter\nprint(sum)\n", "(n, m) = [int(i) for i in input().split()]\narr = []\nfor i in range(n):\n\tl = [a for a in input()]\n\tarr.append(l)\nrow = set()\ncol = set()\nfor i in range(n):\n\tfor j in range(m):\n\t\tif arr[i][j] == 'S':\n\t\t\trow.add(i)\n\t\t\tcol.add(j)\nprint(n * m - len(row) * len(col))\n", "(r, c) = list(map(int, input().split()))\nm = [input() for _ in range(r)]\nprint(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", "(n, m) = map(int, input().split())\nc_n = [1] * m\nc_m = 0\nfor _ in range(n):\n\ts = input()\n\tif 'S' in s:\n\t\tfor i in range(m):\n\t\t\tif s[i] == 'S':\n\t\t\t\tc_n[i] = 0\n\telse:\n\t\tc_m += 1\nprint(c_m * m + c_n.count(1) * (n - c_m))\n", "(n, m) = [int(i) for i in input().split()]\nr = [True] * n\nc = [True] * m\na = []\nk = 0\nfor i in range(n):\n\ta.append(input())\nfor i in range(n):\n\tfor j in range(m):\n\t\tif a[i][j] == 'S':\n\t\t\tr[i] = c[j] = False\nsr = 0\nsc = 0\nfor i in r:\n\tif i:\n\t\tk += m\n\t\tsr += 1\nfor i in c:\n\tif i:\n\t\tk += n\n\t\tsc += 1\nprint(k - sc * sr)\n", "(r, c) = list(map(int, input().split()))\nmatrix = []\ncakes = 0\nfor i in range(r):\n\tdat = input()\n\tif dat.count('S') != 0:\n\t\tmatrix.append(dat)\n\telse:\n\t\tcakes += c\nfor i in range(c):\n\tflag = 0\n\tfor j in range(len(matrix)):\n\t\tif matrix[j][i] == 'S':\n\t\t\tflag = 1\n\t\t\tbreak\n\tif flag == 0:\n\t\tcakes += len(matrix)\nprint(cakes)\n", "iarr = list(map(int, input().split()))\nr = iarr[0]\nc = iarr[1]\narr = []\nflag = [0 for i in range(c)]\nbadrows = 0\nfor i in range(r):\n\ts = input()\n\tarr.append(s)\n\tif s != '.' * c:\n\t\tbadrows += 1\n\tfor i in range(c):\n\t\tif s[i] == 'S':\n\t\t\tflag[i] = 1\nbadcols = sum(flag)\nans = r * c - badrows * badcols\nprint(ans)\n", "(r, c) = [int(i) for i in input().split()]\na = []\nans = 0\nh = r\nfor i in range(r):\n\tcur = list(input().split()[0])\n\tif 'S' not in cur:\n\t\tans += c\n\t\th -= 1\n\telse:\n\t\ta.append(cur)\na_t = list(zip(*a))\nfor elem in a_t:\n\tif 'S' not in elem:\n\t\tans += h\nprint(ans)\n", "(r, c) = map(int, input().split())\nA = []\near = 0\nevc = []\nfor i in range(r):\n\ts = input()\n\tR = []\n\tfor j in range(c):\n\t\tR += [s[j]]\n\tA += [R]\nfor i in range(r):\n\tev = 0\n\tfor j in range(c):\n\t\tif A[i][j] == 'S':\n\t\t\tevc += [j]\n\t\t\tev = 1\n\tif ev == 0:\n\t\tear += 1\nevc = set(evc)\neac = c - len(evc)\nprint(ear * c + (r - ear) * eac)\n", "(r, c) = input().split()\nline = [0] * int(c)\nr_num = 0\nfor _ in [0] * int(r):\n\tS_in = 0\n\tc_num = 0\n\tfor i in input():\n\t\tif i == 'S':\n\t\t\tline[c_num] = 1\n\t\t\tS_in = 1\n\t\tc_num += 1\n\tr_num += S_in\nprint(int(r) * int(c) - r_num * sum(line))\n", "(n, m) = map(int, input().split())\na = []\nb = []\nf = int(0)\nx = int(0)\ncount = int(0)\nfor i in range(n):\n\tb = input()\n\ta.append(b)\nfor i in range(n):\n\tif 'S' not in a[i]:\n\t\tcount = count + m\nx = count // m\nfor i in range(m):\n\tf = 0\n\tfor j in range(n):\n\t\tif 'S' not in a[j][i]:\n\t\t\tf = 1\n\t\telse:\n\t\t\tf = 0\n\t\t\tbreak\n\tif f == 1:\n\t\tcount = count + (n - x)\nprint(count)\n", "import sys\nmy_file = sys.stdin\nline = [int(i) for i in my_file.readline().strip('\\n').split()]\n(r, c) = (line[0], line[1])\ntable = my_file.read().split()\nnew_table = []\nfor line in table:\n\tif 'S' in line:\n\t\tnew_table.append(line)\nres = (len(table) - len(new_table)) * c\nr -= len(table) - len(new_table)\nfor col in range(c):\n\tfor row in range(r):\n\t\tif 'S' in new_table[row][col]:\n\t\t\tbreak\n\telse:\n\t\tres += r\nprint(res)\n", "a = input().split()\nr = int(a[0])\nc = int(a[1])\ns = []\ncr = 0\ncc = 0\nk = 0\nfor i in range(r):\n\ts.append(input())\nfor i in range(r):\n\tif 'S' not in s[i]:\n\t\tcr += 1\nfor i in range(c):\n\tfor j in range(r):\n\t\tif s[j][i] == 'S':\n\t\t\tk = 0\n\t\t\tbreak\n\t\telse:\n\t\t\tk += 1\n\t\tif k == r:\n\t\t\tcc += 1\n\t\t\tk = 0\nprint(cr * c + cc * (r - cr))\n", "import math\n\ndef get_primes(prime_supr):\n\tis_prime = [0] * 2 + [1] * prime_supr\n\tfor i in range(2, int(math.sqrt(prime_supr)) + 1):\n\t\tif is_prime[i]:\n\t\t\tfor j in range(i * i, prime_supr + 1, i):\n\t\t\t\tis_prime[j] = 0\n\treturn is_prime\nget_int = lambda : map(int, input().split())\n(r, c) = get_int()\na = []\nans = 0\nfor i in range(r):\n\ta.append(input())\n\tif 'S' not in a[i]:\n\t\tans += c\n\t\ta[i] = 'u' * c\nfor i in range(c):\n\tif 'S' not in [a[j][i] for j in range(r)]:\n\t\tans += [a[j][i] for j in range(r)].count('.')\nprint(ans)\n", "(r, c) = map(int, input().split())\na = set()\nb = set()\nfor i in range(r):\n\td = input()\n\tfor j in range(len(d)):\n\t\tif d[j] == 'S':\n\t\t\ta.add(j)\n\t\t\tb.add(i)\nprint(r * c - len(a) * len(b))\n", "(n, m) = map(int, input().split())\na = [input() for i in range(n)]\nr = [1 for i in a if 'S' in i]\nl = [1 for i in zip(*a) if 'S' in i]\nprint(n * m - len(r) * len(l))\n", "(r, c) = map(int, input().split())\ncake_row = [input() for i in range(r)]\nfree_row = len([1 for i in cake_row if 'S' not in i])\nfree_col = len([1 for i in zip(*cake_row) if 'S' not in i])\nprint(free_col * (r - free_row) + free_row * c)\n", "(r, c) = map(int, input().split())\ncake = []\ne = 0\nr1 = 0\nst = []\nfor i in range(r):\n\ts = input()\n\tcake.append(s)\nfor i in cake:\n\tif 'S' not in i:\n\t\te += c\n\t\tr1 += 1\n\telse:\n\t\tfor j in range(c):\n\t\t\tif i[j] == 'S':\n\t\t\t\tst.append(j)\ncl = c - len(set(st))\ne1 = (r - r1) * cl\nprint(e + e1)\n", "(r, c) = map(int, input().split())\ngrid = []\nfor _ in range(r):\n\tgrid.append(input())\nfor i in range(r):\n\tif 'S' not in grid[i]:\n\t\tgrid[i] = grid[i].replace('.', '0')\ngrid1 = []\nfor j in range(c):\n\tx = ''\n\tfor i in range(r):\n\t\tx = x + grid[i][j]\n\tgrid1.append(x)\nfor i in range(c):\n\tif 'S' not in grid1[i]:\n\t\tgrid1[i] = grid1[i].replace('.', '0')\nans = 0\nfor i in range(c):\n\tans = ans + grid1[i].count('0')\nprint(ans)\n", "(r, c) = map(int, input().split())\na = 0\nb = []\ne = [list(input()) for i in range(r)]\nfor i in e:\n\tif 'S' in i:\n\t\ta += 1\n\twhile 'S' in i:\n\t\tb.append(i.index('S'))\n\t\ti[i.index('S')] = 0\nprint(int(r * c - a * len(set(b))))\n", "import sys\ntry:\n\tsys.stdin = open(sys.path[0] + '\\\\input.txt', 'r')\n\tsys.stdout = open(sys.path[0] + '\\\\output.txt', 'w')\nexcept Exception as e:\n\tpass\n(r, c) = list(map(int, input().split()))\nrows = set()\ncols = set()\nfor i in range(r):\n\tline = input()\n\tfor j in range(c):\n\t\tif line[j] == 'S':\n\t\t\trows.add(i)\n\t\t\tcols.add(j)\nres = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\tif not (i in rows and j in cols):\n\t\t\tres += 1\nprint(res)\n", "(r, c) = map(int, input().split())\nmat = []\nfor i in range(r):\n\tmat.append(list(str(input())))\n(rr, cc) = (set(), set())\nfor i in range(r):\n\tfor j in range(c):\n\t\tif mat[i][j] == 'S':\n\t\t\trr.add(i)\n\t\t\tcc.add(j)\nprint(r * c - len(rr) * len(cc))\n", "(a, b) = list(map(int, input().split()))\nl = []\nc = 0\ny = 0\nfor i in range(a):\n\tu = input()\n\tl += [u]\n\tif u.count('.') == b:\n\t\ty += 1\n\t\tc += b\nt = ''\nh = 0\nfor i in range(b):\n\tfor j in range(a):\n\t\tt += l[j][i]\n\tif t.count('.') == a:\n\t\th += 1\n\t\tc += a\n\tt = ''\nc = c - h * y\nprint(c)\n", "import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy\nsys.setrecursionlimit(10 ** 7)\ninf = 10 ** 20\nmod = 10 ** 9 + 7\ndd = [(-1, 0), (0, 1), (1, 0), (0, -1)]\nddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]\n\ndef LI():\n\treturn [int(x) for x in sys.stdin.readline().split()]\n\ndef I():\n\treturn int(sys.stdin.readline())\n\ndef F():\n\treturn float(sys.stdin.readline())\n\ndef LS():\n\treturn sys.stdin.readline().split()\n\ndef S():\n\treturn input()\n\ndef main():\n\t(h, w) = LI()\n\tfield = [S() for _ in range(h)]\n\tcheck = [[0] * w for _ in range(h)]\n\tfor i in range(h):\n\t\tf = False\n\t\tfor j in range(w):\n\t\t\tif field[i][j] == 'S':\n\t\t\t\tf = True\n\t\tif not f:\n\t\t\tfor j in range(w):\n\t\t\t\tcheck[i][j] = 1\n\tfor i in range(w):\n\t\tf = False\n\t\tfor j in range(h):\n\t\t\tif field[j][i] == 'S':\n\t\t\t\tf = True\n\t\tif not f:\n\t\t\tfor j in range(h):\n\t\t\t\tcheck[j][i] = 1\n\tans = 0\n\tfor x in check:\n\t\tans += x.count(1)\n\treturn ans\nprint(main())\n", "def main():\n\t[n_rows, n_cols] = [int(_) for _ in input().split()]\n\trows = []\n\tfor _ in range(n_rows):\n\t\trows += [[c for c in input()]]\n\tfor i in range(n_rows):\n\t\tif 'S' not in rows[i]:\n\t\t\trows[i] = ['E'] * n_cols\n\tfor i in range(n_cols):\n\t\tcol = [rows[j][i] for j in range(n_rows)]\n\t\tif 'S' not in col:\n\t\t\tfor j in range(n_rows):\n\t\t\t\trows[j][i] = 'E'\n\tn_eaten = 0\n\tfor i in range(n_rows):\n\t\tn_eaten += sum((rows[i][j] == 'E' for j in range(n_cols)))\n\tprint(n_eaten)\nmain()\n", "def cellsToConsume(matrix):\n\tcolumnsToConsume = 0\n\tfor i in range(len(matrix)):\n\t\tstrawberryFound = False\n\t\tfor j in range(len(matrix[0])):\n\t\t\tif matrix[i][j] == 'S':\n\t\t\t\tstrawberryFound = True\n\t\t\t\tbreak\n\t\tif not strawberryFound:\n\t\t\tcolumnsToConsume += 1\n\trowsToConsume = 0\n\tfor j in range(len(matrix[0])):\n\t\tstrawberryFound = False\n\t\tfor i in range(len(matrix)):\n\t\t\tif matrix[i][j] == 'S':\n\t\t\t\tstrawberryFound = True\n\t\t\t\tbreak\n\t\tif not strawberryFound:\n\t\t\trowsToConsume += 1\n\treturn len(matrix) * rowsToConsume + (len(matrix[0]) - rowsToConsume) * columnsToConsume\n(n, m) = map(int, input().split())\nmatrix = []\nfor _ in range(n):\n\tmatrix.append(input())\nprint(cellsToConsume(matrix))\n", "(n, m) = map(int, input().split())\nmat = []\nfor i in range(n):\n\tp = input()\n\tx = [item for item in p]\n\tmat.append(x)\nrowCount = 0\ncolCount = 0\nfor i in range(n):\n\tz = True\n\tfor j in range(m):\n\t\tif mat[i][j] == 'S':\n\t\t\tz = False\n\t\t\tbreak\n\tif z:\n\t\trowCount += 1\nfor i in range(m):\n\tz = True\n\tfor j in range(n):\n\t\tif mat[j][i] == 'S':\n\t\t\tz = False\n\t\t\tbreak\n\tif z:\n\t\tcolCount += 1\nmi = rowCount * colCount\nprint(rowCount * m + colCount * n - mi)\n", "(bawah, kanan) = map(int, input().split())\nkolom = []\nbaris = []\nfor z in range(bawah):\n\tx = input()\n\tfor zz in range(len(x)):\n\t\tif x[zz] == 'S':\n\t\t\tif zz not in kolom:\n\t\t\t\tkolom.append(zz)\n\t\t\tif z not in baris:\n\t\t\t\tbaris.append(z)\nkebawah = (kanan - len(kolom)) * bawah\nkesamping = (bawah - len(baris)) * (kanan - (kanan - len(kolom)))\nprint(kebawah + kesamping)\n", "(r, c) = list(map(int, input().split()))\nrd = set()\ncd = set()\nfor i in range(r):\n\tfor (j, ele) in enumerate(input()):\n\t\tif ele == 'S':\n\t\t\trd.add(i)\n\t\t\tcd.add(j)\nprint(r * c - len(rd) * len(cd))\n", "(r, c) = input().split()\n(r, c) = (int(r), int(c))\nA = []\nB = []\nfor i in range(0, r):\n\ta = input()\n\tfor j in range(0, c):\n\t\tif a[j] == 'S':\n\t\t\tA.append(i)\n\t\t\tB.append(j)\nA = list(set(A))\nB = list(set(B))\nSum = r * c - len(A) * len(B)\nif Sum > 0:\n\tprint(Sum)\nelse:\n\tprint(0)\n", "(r, c) = list(map(int, input().rstrip().split()))\nl = []\nfor i in range(r):\n\tl.append(input())\n(nor, noc) = (0, 0)\nfor i in l:\n\tif 'S' in i:\n\t\tnor += 1\nfor i in range(c):\n\tif 'S' in [row[i] for row in l]:\n\t\tnoc += 1\nprint(r * c - nor * noc)\n", "(r, c) = map(int, input().split())\na = [input() for i in range(r)]\nb = [[0] * c for i in range(r)]\nfor i in range(r):\n\tif 'S' not in a[i]:\n\t\tfor j in range(c):\n\t\t\tb[i][j] = 1\nfor j in range(c):\n\tis_find = False\n\tfor i in range(r):\n\t\tif a[i][j] == 'S':\n\t\t\tis_find = True\n\t\t\tbreak\n\tif not is_find:\n\t\tfor i in range(r):\n\t\t\tb[i][j] = 1\ncount = 0\nfor i in b:\n\tcount += i.count(1)\nprint(count)\n", "(n, m) = map(int, input().split())\nf = [[False for i in range(m)] for j in range(n)]\nl = []\nfor i in range(n):\n\tk = list(input())\n\tl.append(k)\ne = 0\nfor i in range(n):\n\tif 'S' not in l[i]:\n\t\te += m\n\t\tf[i] = m * [True]\nfor i in range(m):\n\tt = True\n\tr = 0\n\tfor j in range(n):\n\t\tif l[j][i] == 'S':\n\t\t\tt = False\n\t\tif f[j][i] == False:\n\t\t\tr += 1\n\tif t:\n\t\te += r\nprint(e)\n", "(m, n) = map(int, input().split())\nl = []\nl1 = []\nfor i in range(m):\n\ts = input()\n\tl1.append([0] * n)\n\tl.append(s)\ns1 = 0\nfor i in range(m):\n\tc = 0\n\tfor j in range(n):\n\t\tif l[i][j] == 'S':\n\t\t\tc = 1\n\t\t\tbreak\n\tif c == 0:\n\t\tfor j in range(n):\n\t\t\tif l1[i][j] == 0:\n\t\t\t\tl1[i][j] = 1\n\t\t\t\ts1 += 1\nfor i in range(n):\n\tc = 0\n\tfor j in range(m):\n\t\tif l[j][i] == 'S':\n\t\t\tc = 1\n\t\t\tbreak\n\tif c == 0:\n\t\tfor j in range(m):\n\t\t\tif l1[j][i] == 0:\n\t\t\t\tl1[j][i] = 1\n\t\t\t\ts1 += 1\nprint(s1)\n", "import sys\nimport math as m\n\ndef main():\n\tpass\n\ndef binary(n):\n\treturn bin(n).replace('0b', '')\n\ndef decimal(s):\n\treturn int(s, 2)\n\ndef pow2(n):\n\tp = 0\n\twhile n > 1:\n\t\tn //= 2\n\t\tp += 1\n\treturn p\n\ndef isPrime(n):\n\tif n == 1:\n\t\treturn False\n\telse:\n\t\troot = int(n ** 0.5)\n\t\troot += 1\n\t\tfor i in range(2, root):\n\t\t\tif n % i == 0:\n\t\t\t\treturn False\n\t\treturn True\n\ndef lts(l):\n\ts = ''.join(map(str, l))\n\treturn s\n\ndef stl(s):\n\tl = list(s)\n\treturn l\nmod = int(1000000000.0) + 7\n\ndef sinp():\n\treturn sys.stdin.readline().strip()\n\ndef iinp():\n\treturn int(input())\n\ndef ninp():\n\treturn map(int, sys.stdin.readline().strip().split())\n\ndef linp():\n\treturn list(map(int, sys.stdin.readline().strip().split()))\n\ndef p(a):\n\tprint(a)\n\ndef p2(a, b):\n\tprint(a, b)\n(r, c) = ninp()\nbc = []\ncnt = 0\nbr = 0\nfor i in range(r):\n\ts = sinp()\n\tind = 1\n\tf = 0\n\tfor char in s:\n\t\tif char == 'S':\n\t\t\tbc.append(ind)\n\t\t\tf = 1\n\t\tind += 1\n\tif f == 0:\n\t\tcnt = cnt + c\n\t\tbr += 1\nx = set(bc)\ncnt = cnt + (c - len(x)) * (r - br)\np(cnt)\n", "(m, n) = map(int, input().split())\nrows = dict(((i, True) for i in range(m)))\ncols = dict(((j, True) for j in range(n)))\ngraph = [input() for _ in range(m)]\nfor i in range(m):\n\tfor j in range(n):\n\t\tif graph[i][j] == 'S':\n\t\t\trows[i] = False\n\t\t\tcols[j] = False\nans = 0\nfor i in range(m):\n\tfor j in range(n):\n\t\tans += cols[j] or rows[i]\nprint(ans)\n", "(r, c) = map(int, input().split())\nm = []\nfor i in range(r):\n\tm.append(list(input()))\ncnt = 0\nfor i in range(r):\n\tif not 'S' in m[i]:\n\t\tfor j in range(c):\n\t\t\tif m[i][j] == '.':\n\t\t\t\tcnt += 1\n\t\t\t\tm[i][j] = ''\nfor j in range(c):\n\tf = False\n\tfor i in range(r):\n\t\tif m[i][j] == 'S':\n\t\t\tf = True\n\tif f:\n\t\tcontinue\n\tfor i in range(r):\n\t\tif m[i][j] == '.':\n\t\t\tcnt += 1\n\t\t\tm[i][j] = ''\nprint(cnt)\n", "(r, c) = (int(i) for i in input().split(' '))\nm = []\nfor i in range(r):\n\tm.append([i for i in input()])\nt = 0\nfor i in range(len(m)):\n\tif 'S' in m[i]:\n\t\tcontinue\n\telif '.' in m[i]:\n\t\tfor j in range(len(m[i])):\n\t\t\tif m[i][j] == '.':\n\t\t\t\tm[i][j] = 'E'\n\t\t\t\tt += 1\nfor j in range(len(m[0])):\n\ts = False\n\tf = False\n\tkeep = []\n\tfor i in range(len(m)):\n\t\tif m[i][j] == 'S':\n\t\t\ts = True\n\t\t\tcontinue\n\t\telif m[i][j] == '.':\n\t\t\tf = True\n\t\tkeep.append((i, j))\n\tif not s and f:\n\t\tfor k in keep:\n\t\t\tif m[k[0]][k[1]] == '.':\n\t\t\t\tt += 1\n\t\t\t\tm[k[0]][k[1]] = 'E'\nprint(t)\n", "import sys\ninput = sys.stdin.readline\nins = lambda : input().rstrip()\nini = lambda : int(input().rstrip())\ninm = lambda : map(int, input().rstrip().split())\ninl = lambda : list(map(int, input().split()))\nout = lambda x, s='\\n': print(s.join(map(str, x)))\n(r, c) = inm()\ncol = [0] * c\ncount = 0\nfor _ in range(r):\n\ts = ins()\n\tfor i in range(c):\n\t\tcol[i] += 1 if s[i] == '.' else -1\n\tif 'S' not in s:\n\t\tcount += c\nif r == count // c:\n\tprint(count)\nelse:\n\tprint(count + col.count(r) * (r - count // c))\n", "(r, c) = map(int, input().split())\nrow = []\nrs = [0 for i in range(r)]\ncs = [0 for i in range(c)]\ncount = 0\nfor i in range(r):\n\ts = input()\n\trow.append(s)\nfor i in range(r):\n\tfor j in range(c):\n\t\tif row[i][j] == 'S':\n\t\t\trs[i] = 1\n\t\t\tcs[j] = 1\nfor i in range(r):\n\tfor j in range(c):\n\t\tif rs[i] == 0 or cs[j] == 0:\n\t\t\tcount += 1\nprint(count)\n", "(x, z) = input().split()\nx = int(x)\nz = int(z)\nciasto = []\nciasto_inv = []\nfor i in range(x):\n\tciasto.append(list(input()))\nlicz = 0\nfor i in range(x):\n\tif 'S' in ciasto[i]:\n\t\tcontinue\n\tfor j in range(z):\n\t\tif ciasto[i][j] == '.':\n\t\t\tlicz += 1\n\t\t\tciasto[i][j] = '#'\nfor i in range(z):\n\tnowy_wiersz = []\n\tfor j in range(x):\n\t\tnowy_wiersz.append(ciasto[j][i])\n\tciasto_inv.append(nowy_wiersz)\nfor i in range(z):\n\tif 'S' in ciasto_inv[i]:\n\t\tcontinue\n\tfor j in range(x):\n\t\tif ciasto_inv[i][j] == '.':\n\t\t\tlicz += 1\nprint(licz)\n", "l = input().split()\nr = int(l[0])\nc = int(l[1])\nl = []\nnbline = 0\nnbcolone = 0\nfor i in range(r):\n\tl.append(input())\nfor s in l:\n\tif 'S' not in s:\n\t\tnbline += 1\nfor j in range(c):\n\texist = False\n\tfor i in range(r):\n\t\tif l[i][j] == 'S':\n\t\t\texist = True\n\tif exist == False:\n\t\tnbcolone += 1\nprint(nbline * c + nbcolone * r - nbline * nbcolone)\n", "def stri(t, a, b):\n\tl = 0\n\tfor i in range(b):\n\t\tif t[i] == 'S':\n\t\t\ta[i] = 1\n\t\t\tl = -1\n\tif l == 0:\n\t\treturn 0\n\telse:\n\t\treturn -1\n(a, b) = map(int, input().split())\nr = [0] * a\nc = [0] * b\nfor i in range(a):\n\tk = input()\n\tt = stri(k, c, b)\n\tif t == -1:\n\t\tr[i] = 1\nm = r.count(0)\nn = c.count(0)\nprint(m * b + n * a - m * n)\n", "def how_many(rows, cols):\n\tn = 0\n\tfor i in range(len(rows)):\n\t\tif 'S' not in rows[i]:\n\t\t\tfor j in range(len(cols)):\n\t\t\t\trows[i][j] = 'E'\n\t\t\t\tcols[j][i] = 'E'\n\t\t\t\tn += 1\n\tfor j in range(len(cols)):\n\t\tif 'S' not in cols[j]:\n\t\t\tn += cols[j].count('.')\n\treturn n\n\ndef main():\n\tfirst_line = input()\n\tfirst_line = first_line.split()\n\tr = int(first_line[0])\n\tc = int(first_line[1])\n\trows = []\n\tfor i in range(r):\n\t\tline = input()\n\t\trows += [list(line)]\n\tcoloumns = [[rows[i][j] for i in range(r)] for j in range(c)]\n\tprint(how_many(rows, coloumns))\nmain()\n", "(n, m) = list(map(int, input().split()))\nt = []\nfor i in range(n):\n\tt.append(input())\nans = 0\nfor i in range(n):\n\tfor j in range(m):\n\t\ttype = False\n\t\tfor k in range(n):\n\t\t\tif t[k][j] == 'S':\n\t\t\t\ttype = True\n\t\t\t\tbreak\n\t\tif not type:\n\t\t\tans += 1\n\t\telse:\n\t\t\ttype = False\n\t\t\tfor k in range(m):\n\t\t\t\tif t[i][k] == 'S':\n\t\t\t\t\ttype = True\n\t\t\t\t\tbreak\n\t\t\tif not type:\n\t\t\t\tans += 1\nprint(ans)\n", "(r, c) = map(int, input().split())\ncake = []\nfor i in range(r):\n\tcake.append(list(map(str, input())))\nsukses = 0\nfor j in range(r):\n\tif 'S' not in cake[j]:\n\t\tsukses += cake[j].count('.')\n\t\tfor n in range(c):\n\t\t\tcake[j][n] = 'P'\nfor k in range(c):\n\tS = 0\n\tfor l in range(r):\n\t\tif cake[l][k] == 'S':\n\t\t\tS += 1\n\tif S <= 0:\n\t\tfor m in range(r):\n\t\t\tif cake[m][k] == '.':\n\t\t\t\tsukses += 1\nprint(sukses)\n", "(r, c) = [int(i) for i in input().split()]\nrow = []\nans = 0\nfor i in range(r):\n\ts = [ch for ch in input()]\n\tif 'S' not in s:\n\t\tans += c\n\t\ts = 'X' * c\n\trow.append(s)\nfor i in range(c):\n\tcol = []\n\tfor j in range(r):\n\t\tcol.append(row[j][i])\n\tif 'S' not in col:\n\t\tans += col.count('.')\nprint(ans)\n", "def f(j, rows):\n\tc = 0\n\tfor i in range(len(rows)):\n\t\tif rows[i][j] == 'S':\n\t\t\treturn (0, False)\n\t\telif rows[i][j] == '.':\n\t\t\tc += 1\n\treturn (c, True)\n(r, c) = [int(x) for x in input().split()]\nrows = []\nfor i in range(r):\n\trows.append(input())\ncells = 0\nfor i in range(r):\n\tif 'S' not in rows[i]:\n\t\trows[i] = '0' * c\n\t\tcells += c\nfor j in range(c):\n\t(x, y) = f(j, rows)\n\tif y == True:\n\t\tcells += x\nprint(cells)\n", "(n, m) = input().split(' ')\nn = int(n)\nm = int(m)\na = []\nd = []\nf = []\ne = 0\nfor i in range(n):\n\ta.append([])\n\tc = input()\n\tfor j in range(m):\n\t\ta[i].append(c[j])\nfor i in range(n):\n\te = 0\n\tfor j in range(m):\n\t\tif a[i][j] != 'S':\n\t\t\te += 1\n\tif e == m:\n\t\td.append(i)\nfor i in range(m):\n\te = 0\n\tfor j in range(n):\n\t\tif a[j][i] != 'S':\n\t\t\te += 1\n\tif e == n:\n\t\tf.append(i)\nprint(len(d) * m + len(f) * n - len(d) * len(f))\n", "(r, c) = map(int, input().split())\ncake = []\nfor i in range(r):\n\tcake.append(list(input()))\nnr = set()\nnc = set()\nfor i in range(r):\n\tif 'S' in cake[i]:\n\t\tnr.add(i)\nfor i in range(c):\n\tfor j in range(r):\n\t\tif cake[j][i] == 'S':\n\t\t\tnc.add(i)\n\t\t\tbreak\nfor i in range(r):\n\tif i not in nr:\n\t\tfor j in range(c):\n\t\t\tcake[i][j] = 'o'\nfor i in range(c):\n\tif i not in nc:\n\t\tfor j in range(r):\n\t\t\tcake[j][i] = 'o'\nret = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\tif cake[i][j] == 'o':\n\t\t\tret += 1\nprint(ret)\n", "(r, c) = map(int, input().split())\neat = 0\nf = []\nfor i in range(c):\n\tf.append([])\nfor i in range(r):\n\tk = list(str(input()))\n\tif k.count('S') == 0:\n\t\tfor j in range(c):\n\t\t\tk[j] = 'E'\n\t\teat += c\n\tfor j in range(c):\n\t\tf[j].append(k[j])\nfor i in range(c):\n\tif f[i].count('S') == 0:\n\t\teat += f[i].count('.')\nprint(eat)\n", "(r, c) = map(int, input().split())\nl = []\n(rs, cs) = (0, 0)\nfor _ in range(r):\n\ts = input()\n\trs += 'S' in s\n\tl.append(s)\nfor i in range(c):\n\tfor j in range(r):\n\t\tif l[j][i] == 'S':\n\t\t\tcs += 1\n\t\t\tbreak\nrs = r - rs\ncs = c - cs\nans = rs * c + cs * r - rs * cs\nprint(ans)\n", "import sys\nfrom collections import defaultdict\n(r, c) = map(int, sys.stdin.readline().split())\ngrid = list(map(lambda l: sys.stdin.readline().strip(), range(r)))\nfrow = defaultdict(lambda : False)\nfcol = defaultdict(lambda : False)\nfor i in range(r):\n\tfor j in range(c):\n\t\tif grid[i][j] == 'S':\n\t\t\tfrow[i] = True\n\t\t\tfcol[j] = True\nans = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\tif not frow[i] or not fcol[j]:\n\t\t\tans += 1\nsys.stdout.write(str(ans))\n", "def cakeminator(r, c, alist):\n\tcollist = []\n\tfor i in range(0, c):\n\t\tisColEditable = True\n\t\tisCakeAvailable = False\n\t\tfor j in range(0, r):\n\t\t\tif alist[j][i] == '.':\n\t\t\t\tisCakeAvailable = True\n\t\t\telif alist[j][i] == 'S':\n\t\t\t\tisColEditable = False\n\t\tif isCakeAvailable and isColEditable:\n\t\t\tcollist.append(i)\n\trowlist = []\n\tallRowsEdibleCount = 0\n\tfor i in range(0, r):\n\t\tthisRowEdibleCount = 0\n\t\tisRowEditable = True\n\t\tisCakeAvailable = False\n\t\tfor j in range(0, c):\n\t\t\tif alist[i][j] == '.' and (not j in collist):\n\t\t\t\tisCakeAvailable = True\n\t\t\t\tthisRowEdibleCount += 1\n\t\t\telif alist[i][j] == 'S':\n\t\t\t\tisRowEditable = False\n\t\tif isCakeAvailable and isRowEditable:\n\t\t\trowlist.append(i)\n\t\t\tallRowsEdibleCount += thisRowEdibleCount\n\treturn len(collist) * r + allRowsEdibleCount\n(n, m) = map(int, input().split())\nblist = []\nfor i in range(n):\n\tb = input()\n\talist = list(b)\n\tblist.append(alist)\nprint(cakeminator(n, m, blist))\n", "(r, c) = map(int, input().split())\nrows = set()\ncols = set()\nfor ri in range(r):\n\ts = input().strip()\n\tfor ci in range(c):\n\t\tif s[ci] == 'S':\n\t\t\trows.add(ri)\n\t\t\tcols.add(ci)\nprint(r * c - len(rows) * len(cols))\n", "a = [int(n) for n in input().split(' ')]\nn = a[0]\nm = a[1]\nr = []\nc = 0\nt = []\nfor i in range(n):\n\tk = 0\n\ts = str(input())\n\tfor j in range(len(s)):\n\t\tif s[j] == 'S':\n\t\t\tk = k + 1\n\t\t\tr.append(j)\n\tif k > 0:\n\t\tc = c + 1\nfor i in range(len(r)):\n\tif t.count(r[i]) == 0:\n\t\tt.append(r[i])\np = len(t)\nprint(n * m - c * p)\n", "s = input().split()\nr = int(s[0])\nc = int(s[1])\na = []\ne = 0\nf = 0\nfor i in range(r):\n\td = input()\n\tlist(d)\n\ta.append(d)\nfor i in a:\n\tif i.find('S') == -1:\n\t\te += 1\nfor i in range(c):\n\tz = 0\n\tfor d in range(r):\n\t\tif a[d][i] == 'S':\n\t\t\tz = 1\n\tif z == 0:\n\t\tf += 1\nprint(e * c + f * (r - e))\n", "x = list(map(int, input().split()))\nr = x[0]\nc = x[1]\nl = []\nmat = [[0] * c for i in range(r)]\nrows = set()\ncols = set()\nfor i in range(r):\n\tl.append(str(input()))\nfor i in range(r):\n\tfor j in range(c):\n\t\tif l[i][j] == '.':\n\t\t\tmat[i][j] = 1\n\t\telif l[i][j] == 'S':\n\t\t\tmat[i][j] = 2\n\t\t\trows.add(i)\n\t\t\tcols.add(j)\ncnt = 0\nfor i in range(r):\n\tif i not in rows:\n\t\tfor j in range(c):\n\t\t\tmat[i][j] = 0\n\t\t\tcnt += 1\nfor j in range(c):\n\tif j not in cols:\n\t\tfor i in range(r):\n\t\t\tif mat[i][j] == 1:\n\t\t\t\tmat[i][j] = 0\n\t\t\t\tcnt += 1\nprint(cnt)\n", "(r, c) = map(int, input().split(sep=' '))\n(a, l) = (list(), list())\nn = 0\nfor i in range(r):\n\ta.append(input()[0:c])\nfor i in range(r):\n\tfor j in range(c):\n\t\tif a[i][j] == 'S':\n\t\t\tn += 1\n\t\t\tl.append([i, j])\nk = list()\nfor i in l:\n\tfor j in l:\n\t\tif i != j and [j[0], i[1]] not in l:\n\t\t\tif [j[0], i[1]] not in k:\n\t\t\t\tk.append([j[0], i[1]])\nn += k.__len__()\nprint(r * c - n)\n", "l = input().split()\n(row, col) = (int(l[0]), int(l[1]))\ncount = 0\nrowDic = {}\ncolDic = {}\nstrawCount = 0\nwhile count < row:\n\tl = input()\n\tfor i in range(len(l)):\n\t\tif l[i] == 'S':\n\t\t\trowDic[count] = 1\n\t\t\tcolDic[i] = 1\n\t\t\tstrawCount += 1\n\tcount += 1\ncantEat = 0\nif strawCount:\n\tfor i in range(row):\n\t\tfor j in range(col):\n\t\t\tif rowDic.get(i, 0) > 0 and colDic.get(j, 0) > 0:\n\t\t\t\tcantEat += 1\nprint(row * col - cantEat)\n", "(r, c) = map(int, input().split())\nr0 = []\nc0 = []\nfor i in range(r):\n\ts = input()\n\tfor j in range(c):\n\t\tif s[j] == 'S':\n\t\t\tr0.append(i)\n\t\t\tc0.append(j)\nr0 = set(r0)\nc0 = set(c0)\nprint(r * c - len(r0) * len(c0))\n", "(r, c) = map(int, input().split())\na = []\n[a.append(input()) for _ in range(r)]\nk = 0\nt = 0\nfor i in range(r - 1, -1, -1):\n\tif 'S' in a[i]:\n\t\tcontinue\n\telse:\n\t\tk += len(a[i])\n\t\ta.remove(a[i])\n\t\tr -= 1\nfor j in range(c):\n\tfor i in range(r):\n\t\tif a[i][j] == 'S':\n\t\t\tcontinue\n\t\telse:\n\t\t\tt += 1\n\tif t == r:\n\t\tk += t\n\tt = 0\nprint(k)\n", "(n, m) = map(int, input().split())\nl = []\nc = 0\nfor i in range(n):\n\ts = input()\n\tif 'S' not in s:\n\t\tc += m\n\telse:\n\t\tl.append(s)\nfor i in range(m):\n\ts1 = 0\n\tfor j in range(len(l)):\n\t\tif l[j][i] != 'S':\n\t\t\ts1 += 1\n\t\telse:\n\t\t\ts1 = 0\n\t\t\tbreak\n\tc += s1\nprint(c)\n", "(r, c) = map(int, input().split())\nmat = []\nfor i in range(r):\n\tmat.append(list(input()))\nrw = []\ncl = []\nfor i in range(r):\n\tfor j in range(c):\n\t\tif mat[i][j] == 'S':\n\t\t\trw.append(i)\n\t\t\tcl.append(j)\nk = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\tif i in rw and j in cl:\n\t\t\tk += 1\nprint(r * c - k)\n", "grid = [int(i) for i in input().split(' ')]\nr = grid[0]\nc = grid[1]\ne_c = set()\ne_r = set()\nfor i in range(r):\n\tt = list(input())\n\tfor j in range(len(t)):\n\t\tif t[j] == 'S':\n\t\t\te_c = e_c | set([j])\n\t\t\te_r = e_r | set([i])\nprint(r * c - len(e_r) * len(e_c))\n", "(r, c) = map(int, input().strip().split())\ng = []\nfor i in range(0, r):\n\tg.append(list(input().strip()))\nres = 0\nfor i in g:\n\tif 'S' not in i:\n\t\tfor j in range(0, c):\n\t\t\tif i[j] == '.':\n\t\t\t\tres += 1\n\t\t\t\ti[j] = -1\ng_t = [[] for a in range(0, c)]\nfor i in range(0, c):\n\tfor j in range(0, r):\n\t\tg_t[i].append(g[j][i])\nfor i in g_t:\n\tif 'S' not in i:\n\t\tfor j in range(0, r):\n\t\t\tif i[j] == '.':\n\t\t\t\tres += 1\n\t\t\t\ti[j] = -1\nprint(res)\n", "import math\n\ndef main():\n\t(r, c) = map(int, input().split())\n\tg = [[] for _ in range(r)]\n\tfor row in range(r):\n\t\tg[row] = list(input())\n\tfor row in range(r):\n\t\tif not 'S' in g[row]:\n\t\t\tfor col in range(c):\n\t\t\t\tg[row][col] = '*'\n\tfor col in range(c):\n\t\tok = True\n\t\tfor row in range(r):\n\t\t\tif g[row][col] == 'S':\n\t\t\t\tok = False\n\t\t\t\tbreak\n\t\tif ok:\n\t\t\tfor row in range(r):\n\t\t\t\tg[row][col] = '*'\n\tres = 0\n\tfor row in range(r):\n\t\tfor col in range(c):\n\t\t\tif g[row][col] == '*':\n\t\t\t\tres += 1\n\tprint(res)\nmain()\n", "def eat_cake(cols, rows, string):\n\tresult = 0\n\tfor i in range(0, rows):\n\t\tif 'S' not in string[i]:\n\t\t\tresult += cols\n\t\t\tstring[i] = string[i].replace('.', 'E')\n\tfor i in range(0, cols):\n\t\tcontains = False\n\t\tall_eaten = True\n\t\talready_eaten = 0\n\t\tfor j in range(0, rows):\n\t\t\tif string[j][i] == 'S':\n\t\t\t\tcontains = True\n\t\t\tif string[j][i] == '.':\n\t\t\t\tall_eaten = False\n\t\t\tif string[j][i] == 'E':\n\t\t\t\talready_eaten += 1\n\t\tif all_eaten == False and contains == False:\n\t\t\tresult += rows - already_eaten\n\t\t\tfor row in range(0, rows):\n\t\t\t\tstring[row] = string[row][0:i] + 'E' + string[row][i + 1:]\n\treturn result\n\ndef main():\n\tfirst_line = input()\n\tfirst_line = first_line.split()\n\trows = int(first_line[0])\n\tcoloumns = int(first_line[1])\n\tl = []\n\tfor i in range(rows):\n\t\tline = input()\n\t\tl.append(line)\n\tprint(eat_cake(coloumns, rows, l))\nmain()\n", "(r, c) = map(int, input().split())\nv = [1] * c\nd = 0\nfor _ in range(r):\n\ts = list(input())\n\tfor i in range(len(s)):\n\t\tif s[i] == 'S':\n\t\t\tv[i] = 0\n\tif 'S' not in s:\n\t\td += 1\nf = sum(v)\nprint(d * c + r * f - d * f)\n", "(n, m) = map(int, input().split())\na = []\ncount = 0\nr = 0\ncol = 0\ns = 0\nz = 0\nx = 0\ny = 0\nfor i in range(n):\n\ta.append(list(input()))\nwhile n * m >= z:\n\tz += 1\n\tif x == n:\n\t\tbreak\n\tif a[x][y] == '.' and y < m:\n\t\ty += 1\n\t\tif y == m:\n\t\t\tx += 1\n\t\t\ty = 0\n\t\t\tr += 1\n\t\t\tcount += m\n\telif a[x][y] == 'S' and x < n:\n\t\tx += 1\n\t\ty = 0\nx = 0\ny = 0\nwhile n * m >= s:\n\ts += 1\n\tif y == m:\n\t\tbreak\n\tif a[x][y] == '.' and x < n:\n\t\tx += 1\n\t\tif x == n:\n\t\t\ty += 1\n\t\t\tx = 0\n\t\t\tcol += 1\n\t\t\tcount += n\n\telif a[x][y] == 'S' and y < m:\n\t\ty += 1\n\t\tx = 0\ncount = count - r * col\nprint(count)\n", "(n, m) = map(int, input().split())\nt = []\nfor i in range(n):\n\tr = input()\n\tif 'S' in r:\n\t\tt.append(r)\ns = set()\nfor i in t:\n\tfor j in range(m):\n\t\tif i[j] == 'S':\n\t\t\ts.add(j)\nprint(m * n - len(t) * len(s))\n", "(n, m) = map(int, input().split())\nlst = [list(input()) for _ in range(n)]\ncount = 0\nfor j in range(m):\n\tcol = [lst[k][j] for k in range(n)]\n\tif 'S' not in col:\n\t\tfor i in range(n):\n\t\t\tif lst[i][j] == '.':\n\t\t\t\tcount += 1\n\t\t\t\tlst[i][j] = '*'\nfor i in range(n):\n\tif 'S' in lst[i]:\n\t\tcontinue\n\telse:\n\t\tfor j in range(m):\n\t\t\tif lst[i][j] == '.':\n\t\t\t\tcount += 1\n\t\t\t\tlst[i][j] = '*'\nprint(count)\n", "(r, c) = input().split()\n(r, c) = (int(r), int(c))\nsol = 0\ncols = set()\ncolsub = 0\nfor i in range(r):\n\ts = input()\n\tstraw = False\n\tfor j in range(c):\n\t\tif s[j] == 'S':\n\t\t\tstraw = True\n\t\t\tcols.add(j)\n\tif not straw:\n\t\tsol += c\n\t\tcolsub += 1\nsol += (c - len(cols)) * r - (c - len(cols)) * colsub\nprint(sol)\n", "count = 0\nsrr = ''\n(p, l) = map(int, input().split())\ngrid = []\nfor i in range(p):\n\tgrid.append(input())\nfor i in range(p):\n\tif 'S' not in grid[i]:\n\t\tfor j in grid[i]:\n\t\t\tsrr = srr + '1'\n\t\tgrid[i] = srr\n\t\tcount = count + l\nfor i in range(l):\n\tflag = 0\n\tfor j in range(p):\n\t\tif 'S' == grid[j][i]:\n\t\t\tflag = 1\n\t\t\tbreak\n\tif flag == 0:\n\t\tfor k in range(p):\n\t\t\tif grid[k][i] == '.':\n\t\t\t\tcount = count + 1\nprint(count)\n", "(r, c) = input().split()\nr = int(r)\nc = int(c)\narr = []\nrp = 0\nsum = 0\ncol_set = []\nfor i in range(r):\n\tarr.append(input())\n\ttry:\n\t\tarr[i].index('S')\n\t\tfor j in range(len(arr[i])):\n\t\t\tif arr[i][j] == 'S':\n\t\t\t\tcol_set.append(j)\n\texcept:\n\t\trp += 1\n\t\tsum += c\nfor i in range(c):\n\tif i not in col_set:\n\t\tsum = sum + r - rp\nprint(sum)\n", "(r, c) = map(int, input().split())\ns = set()\ne = set()\nfor i in range(r):\n\ttmp = input()\n\tfor j in range(c):\n\t\tif tmp[j] == 'S':\n\t\t\ts.add((i, j))\nfor s1 in s:\n\tfor s2 in s:\n\t\tif s1 != s2 and (s1[0] != s2[0] or s1[1] != s2[1]):\n\t\t\te.add((s1[0], s2[1]))\n\t\t\te.add((s2[0], s1[1]))\nprint(r * c - len(s.union(e)))\n", "(n, k) = map(int, input().split())\na = []\nc = []\nx = 0\nd = 0\nfor i in range(n):\n\ta.append(input())\nfor i in range(n - 1, -1, -1):\n\tif not 'S' in a[i]:\n\t\tx += len(a[i])\n\t\tdel a[i]\n\t\td += 1\nfor i in range(k):\n\tb = []\n\tfor j in range(n - d):\n\t\tb.append(a[j][i])\n\tc.append(b)\n\tc[i] = ''.join(c[i])\nfor i in range(k - 1, -1, -1):\n\tif not 'S' in c[i]:\n\t\tx += len(c[i])\n\t\tdel c[i]\n\t\td += 1\nprint(x)\n", "import sys\nfin = sys.stdin\n(n, m) = map(int, fin.readline().split())\nisRowFree = [True] * n\nisColFree = [True] * m\nfor i in range(n):\n\ts = fin.readline().strip()\n\tfor j in range(m):\n\t\tif s[j] == 'S':\n\t\t\tisRowFree[i] = False\n\t\t\tisColFree[j] = False\n\ndef FreeRows():\n\treturn sum((1 for i in range(n) if isRowFree[i]))\n\ndef FreeColumns():\n\treturn sum((1 for i in range(m) if isColFree[i]))\na = FreeRows()\nb = FreeColumns()\nprint(a * m + b * (n - a))\n", "(a, b) = [int(i) for i in input().split()]\nc = [input() for j in range(a)]\nd1 = 0\nd2 = 0\nd = False\nfor i in range(a):\n\tif 'S' not in c[i]:\n\t\td1 += b\nfor i in range(b):\n\td = False\n\tfor j in range(a):\n\t\tif c[j][i] == 'S':\n\t\t\td = True\n\t\t\tbreak\n\tif not d:\n\t\td2 += a\nprint(int(d1 + d2 - d2 / a * (d1 / b)))\n", "(r, c) = map(int, input().split())\nm = []\nans = 0\nfor k in range(r):\n\ta = input()\n\tif 'S' not in a:\n\t\tans = ans + c\n\telse:\n\t\tap = list(a)\n\t\tm.append(ap)\nfor j in range(c):\n\tco = []\n\tfor k in range(len(m)):\n\t\tco.append(m[k][j])\n\tif 'S' not in co:\n\t\tans = ans + len(m)\nprint(ans)\n", "def solve():\n\t(n, m) = list(map(int, input().split()))\n\tl = list()\n\tfor i in range(n):\n\t\tl.append(input())\n\t(flag, row, col) = (1, 0, 0)\n\tfor i in range(n):\n\t\tfor j in range(m):\n\t\t\tif l[i][j] == 'S':\n\t\t\t\tflag = 0\n\t\tif flag:\n\t\t\trow += 1\n\t\tflag = 1\n\tflag = 1\n\tfor i in range(m):\n\t\tfor j in range(n):\n\t\t\tif l[j][i] == 'S':\n\t\t\t\tflag = 0\n\t\tif flag:\n\t\t\tcol += 1\n\t\tflag = 1\n\tprint(row * m + col * n - row * col)\nt = 1\nfor _ in range(t):\n\tsolve()\n", "(r, k) = [int(i) for i in input().split()]\na = []\nc = []\n(ro, ko) = (0, 0)\nfor i in range(r):\n\tb = []\n\ts = input()\n\tfor f in s:\n\t\tif f == 'S':\n\t\t\tro += 1\n\t\t\tbreak\n\tfor j in range(k):\n\t\tb.append(s[j])\n\ta.append(b)\nfor j in range(k):\n\tfor i in range(r):\n\t\tif a[i][j] == 'S':\n\t\t\tko += 1\n\t\t\tbreak\nprint((r - ro) * k + (k - ko) * ro)\n", "grid = input()\nr = int(grid.split()[0])\nrl = []\ncl = []\nwhile r > 0:\n\tc = input()\n\tfor (index, i) in enumerate(c):\n\t\tif i == 'S':\n\t\t\tcl.append(index)\n\t\t\trl.append(r)\n\tr -= 1\nprint(int(grid.split()[0]) * int(grid.split()[1]) - len(set(rl)) * len(set(cl)))\n", "(n, k) = map(int, input().split())\nar = []\nrow = 0\ncol = 0\ncount = 0\nfor i in range(n):\n\tar.append(input())\n\tif 'S' not in ar[i]:\n\t\trow += 1\nfor i in range(k):\n\tcount = 0\n\tfor j in range(n):\n\t\tif ar[j][i] == 'S':\n\t\t\tcount = 1\n\t\t\tbreak\n\tif count == 0:\n\t\tcol += 1\nprint(col * n + row * k - row * col)\n", "(r, c) = [int(s) for s in input().split()]\ncake = []\nrow = 0\ncolumn = 0\nfor i in range(r):\n\tline = input()\n\tcake.append(line)\n\tif 'S' not in line:\n\t\trow += 1\nfor i in range(c):\n\ts = 0\n\tfor j in range(r):\n\t\tif cake[j][i] == 'S':\n\t\t\ts += 1\n\tif s == 0:\n\t\tcolumn += 1\nprint(row * c + column * r - row * column)\n", "(r, c) = map(int, input().split())\narr = [input() for i in range(r)]\na = 0\nb = []\ng = []\nd = []\nfor i in range(r):\n\tfor j in range(c):\n\t\tif arr[i][j] == 'S':\n\t\t\ta += 1\n\t\t\tb.append([i, j])\nfor k in range(a):\n\tg.append(b[k][0])\ne = set(g)\ng = list(e)\nfor k in range(a):\n\td.append(b[k][1])\nf = set(d)\nd = list(f)\nz = (r - len(g)) * c + (c - len(d)) * (r - (r - len(g)))\nprint(z)\n", "def single_integer():\n\treturn int(input())\n\ndef multi_integer():\n\treturn map(int, input().split())\n\ndef string():\n\treturn input()\n\ndef multi_string():\n\treturn input().split()\n(r, c) = multi_integer()\ncolumns = set()\ngood_row = 0\nans = 0\nfor i in range(r):\n\tk = 0\n\tcount = 0\n\trow = string()\n\tfor j in row:\n\t\tif j == 'S':\n\t\t\tcount += 1\n\t\t\tcolumns.add(k)\n\t\tk += 1\n\tif count == 0:\n\t\tgood_row += 1\n\t\tans += c\nprint(ans + (c - len(columns)) * (r - good_row))\n", "[n, m] = list(map(int, input().split(' ')))\ncr = [1] * n\ncc = [1] * m\nfor i in range(n):\n\ts = input()\n\tfor j in range(m):\n\t\tcr[i] = 0 if s[j] == 'S' else cr[i]\n\t\tcc[j] = 0 if s[j] == 'S' else cc[j]\nsr = sum(cr)\nsc = sum(cc)\nresult = sr * m + sc * n - sr * sc\nprint(result)\n", "(r, c) = map(int, input().split())\ncake = []\nfor _ in range(r):\n\ttmp = list(input())\n\ttmp = [0 if i == '.' else 1 for i in tmp]\n\tcake.append(tmp)\np = 0\ntr = 0\nfor i in range(r):\n\tif sum(cake[i]) == 0:\n\t\tp += c\n\t\ttr += 1\nfor i in range(c):\n\ttmp = 0\n\tfor j in range(r):\n\t\ttmp += cake[j][i]\n\tif tmp == 0:\n\t\tp += r - tr\nprint(p)\n", "class CodeforcesTask330ASolution:\n\n\tdef __init__(self):\n\t\tself.result = ''\n\t\tself.r_c = []\n\t\tself.cake = []\n\n\tdef read_input(self):\n\t\tself.r_c = [int(x) for x in input().split(' ')]\n\t\tfor r in range(self.r_c[0]):\n\t\t\tself.cake.append(list(input()))\n\n\tdef process_task(self):\n\t\tfor r in range(self.r_c[0]):\n\t\t\tfor c in range(self.r_c[1]):\n\t\t\t\tif self.cake[r][c] == 'S':\n\t\t\t\t\tfor x in range(self.r_c[0]):\n\t\t\t\t\t\tif self.cake[x][c] == '.':\n\t\t\t\t\t\t\tself.cake[x][c] = 'r'\n\t\t\t\t\t\telif self.cake[x][c] == 's':\n\t\t\t\t\t\t\tself.cake[x][c] = 'S'\n\t\t\t\t\tfor y in range(self.r_c[1]):\n\t\t\t\t\t\tif self.cake[r][y] == '.':\n\t\t\t\t\t\t\tself.cake[r][y] = 's'\n\t\t\t\t\t\telif self.cake[r][y] == 'r':\n\t\t\t\t\t\t\tself.cake[r][y] = 'S'\n\t\tself.result = str(self.r_c[0] * self.r_c[1] - ''.join([''.join(x) for x in self.cake]).count('S'))\n\n\tdef get_result(self):\n\t\treturn self.result\nSolution = CodeforcesTask330ASolution()\nSolution.read_input()\nSolution.process_task()\nprint(Solution.get_result())\n", "(r, c) = map(int, input().split())\nL = [str(input()) for _ in range(r)]\nC = [0 for _ in range(c)]\nR = [0 for _ in range(r)]\nfor i in range(r):\n\tfor j in range(c):\n\t\tif L[i][j] == 'S':\n\t\t\tR[i] = 1\n\t\t\tC[j] = 1\nprint(r * c - sum(C) * sum(R))\n", "(n, m) = map(int, input().split())\nb = []\nb1 = []\nc = 0\nfor i in range(n):\n\ta = str(input())\n\tb.append(a)\nfor i in range(len(b)):\n\tif 'S' not in b[i]:\n\t\tc += len(b[i])\n\t\tb1.append(i)\nb1.reverse()\nfor i in b1:\n\tdel b[i]\nfor j in range(m):\n\tfor i in range(len(b)):\n\t\tif b[i][j] == 'S':\n\t\t\tbreak\n\telse:\n\t\tc += len(b)\nprint(c)\n", "(R, C) = map(int, input().split())\nmatrix = []\nrow = set()\ncol = set()\nfor i in range(R):\n\ttemp = input().strip()\n\tfor j in range(C):\n\t\tif temp[j] == 'S':\n\t\t\trow.add(i)\n\t\t\tcol.add(j)\nprint(R * C - len(row) * len(col))\n", "(N, M) = map(int, input().split())\nL = []\ncount = 0\nfor i in range(N):\n\tL.append(list(input()))\nfor i in range(N):\n\tfor j in range(M):\n\t\t(FLAG1, FLAG2) = (0, 0)\n\t\tif L[i][j] == '.':\n\t\t\tfor k in range(M):\n\t\t\t\tif L[i][k] == 'S':\n\t\t\t\t\tFLAG1 = 1\n\t\t\t\t\tbreak\n\t\t\tfor l in range(N):\n\t\t\t\tif L[l][j] == 'S':\n\t\t\t\t\tFLAG2 = 1\n\t\t\t\t\tbreak\n\t\t\tif FLAG1 == 0 or FLAG2 == 0:\n\t\t\t\tcount += 1\nprint(count)\n", "(r, c) = map(int, input().split())\n(row, col) = ([False] * r, [False] * c)\ngrid = []\nfor i in range(r):\n\tgrid.append(input())\n\tfor j in range(c):\n\t\tif grid[i][j] == 'S':\n\t\t\trow[i] = col[j] = True\ncont = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\tcont += not (row[i] and col[j])\nprint(cont)\n", "(n, m) = map(int, input().split())\nl = [input() for _ in range(n)]\nfrom collections import Counter\ns = []\nk = 0\nfor i in range(n):\n\tif 'S' not in l[i]:\n\t\tk = k + 1\n\tfor j in range(m):\n\t\tif l[i][j] == 'S':\n\t\t\ts.append(j + 1)\nx = len(Counter(s))\nprint(k * m + (m - x) * n - k * (m - x))\n", "import sys\n\ndef input():\n\treturn sys.stdin.readline().strip()\n\ndef iinput():\n\treturn int(input())\n\ndef rinput():\n\treturn map(int, sys.stdin.readline().strip().split())\n\ndef get_list():\n\treturn list(map(int, sys.stdin.readline().strip().split()))\n(r, c) = rinput()\na = []\nfor i in range(r):\n\ts = list(input())\n\ta.append(s)\ncount = 0\ncount1 = 0\nfor i in range(r):\n\tif a[i] == ['.'] * c:\n\t\tcount += 1\nif count == r:\n\tprint(r * c)\nelse:\n\tans = count * c\n\ti = 0\n\tfor j in range(c):\n\t\tfor i in range(r):\n\t\t\tif a[i][j] == 'S':\n\t\t\t\tcount1 += 1\n\t\t\t\tbreak\n\tcol = c - count1\n\tans += col * r\n\tans -= count * col\n\tprint(ans)\n", "def cakeminator(cake, r, c):\n\ttotal = 0\n\tfor i in range(r):\n\t\tif 'S' not in cake[i]:\n\t\t\tfor j in range(c):\n\t\t\t\tif cake[i][j] == '.':\n\t\t\t\t\tcake[i][j] = 'x'\n\t\t\t\t\ttotal += 1\n\tfor i in range(c):\n\t\tres = []\n\t\tfor j in range(r):\n\t\t\tres.append(cake[j][i])\n\t\tif 'S' not in res:\n\t\t\ttotal += res.count('.')\n\treturn total\n\ndef mkcake(r, c):\n\tcake = []\n\tfor i in range(r):\n\t\ts = list(input())\n\t\tcake.append(s)\n\treturn cake\n\ndef main():\n\t(r, c) = map(int, input().split())\n\tcake = mkcake(r, c)\n\tprint(cakeminator(cake, r, c))\nmain()\n", "(rows, columns) = map(int, input().split())\noccupied_rows = 0\noccupied_columns_set = set()\nfor i in range(rows):\n\tline = input()\n\tif 'S' not in line:\n\t\tcontinue\n\toccupied_rows += 1\n\t[occupied_columns_set.add(j) for j in range(columns) if line[j] == 'S']\noccupied_columns = len(occupied_columns_set)\nprint(columns * rows - occupied_columns * occupied_rows)\n", "def cmget(s):\n\ti = 0\n\tlis = []\n\tfor ch in s:\n\t\tif ch == 'S':\n\t\t\tlis.append(i)\n\t\ti += 1\n\treturn lis\n(r, c) = map(int, input().split())\ngrid = []\nrm = set()\ncm = set()\nfor i in range(r):\n\ts = input()\n\tif 'S' in s:\n\t\trm.add(i)\n\t\tlis = cmget(s)\n\t\tfor i in lis:\n\t\t\tcm.add(i)\n\tgrid.append(s)\nres = 0\nfor i in range(r):\n\tfor j in range(len(grid[i])):\n\t\tif i in rm and j in cm:\n\t\t\tres += 1\nprint(r * c - res)\n", "(r, c) = map(int, input().split())\ncake = []\nfor i in range(r):\n\tcake.append(list(input()))\nres = 0\nfor i in cake:\n\tif 'S' not in i:\n\t\tres += c\n\t\tfor j in range(len(i)):\n\t\t\ti[j] = None\nfor i in range(c):\n\tf = 1\n\tfor j in range(r):\n\t\tif cake[j][i] == 'S':\n\t\t\tf = 0\n\t\t\tbreak\n\tif f:\n\t\tfor j in range(r):\n\t\t\tif cake[j][i] is not None:\n\t\t\t\tres += 1\nprint(res)\n", "(r, c) = map(int, input().split())\ndata = [list(input()) for i in range(r)]\ntotal = 0\nfor i in range(r):\n\tif 'S' not in data[i]:\n\t\ttotal += c\nrow = total // c\nfor j in range(c):\n\tfor k in range(r):\n\t\tif data[k][j] == 'S':\n\t\t\tbreak\n\telse:\n\t\ttotal = total + r - row\nprint(total)\n", "(n, m) = [int(x) for x in input().split()]\na = []\nans = 0\nfor i in range(n):\n\ta.append(list(input()))\nfor i in range(n):\n\tflag = 1\n\tfor j in range(m):\n\t\tif a[i][j] == 'S':\n\t\t\tflag = 0\n\tif flag == 1:\n\t\tfor j in range(m):\n\t\t\ta[i][j] = 'T'\nfor i in range(m):\n\tflag = 1\n\tfor j in range(n):\n\t\tif a[j][i] == 'S':\n\t\t\tflag = 0\n\tif flag == 1:\n\t\tfor j in range(n):\n\t\t\ta[j][i] = 'T'\nfor i in range(n):\n\tfor j in range(m):\n\t\tif a[i][j] == 'T':\n\t\t\tans += 1\nprint(ans)\n", "(r, c) = map(int, input().split())\ncake = [input().strip() for _ in range(r)]\nans = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\tif cake[i][j] == '.' and ('S' not in cake[i] or 'S' not in list(zip(*cake))[j]):\n\t\t\tans += 1\nprint(ans)\n", "(r, c) = [int(x) for x in input().split(' ')]\ngrid = []\nfor _ in range(r):\n\tgrid.append([x for x in input()])\nfor x in range(r):\n\tif 'S' not in grid[x]:\n\t\tgrid[x] = ['1' for i in range(c)]\nfor x in range(c):\n\ttemp = []\n\tfor row in range(r):\n\t\ttemp.append(grid[row][x])\n\tif 'S' not in temp:\n\t\tfor row in range(r):\n\t\t\tgrid[row][x] = '1'\nans = 0\nfor x in range(r):\n\tans += grid[x].count('1')\nprint(ans)\n", "(n, m) = map(int, input().split())\narr = [str(input()) for i in range(n)]\ncnt_row = [0 for i in range(n)]\ncnt_col = [0 for i in range(m)]\nfor i in range(n):\n\tfor j in range(m):\n\t\tif arr[i][j] == 'S':\n\t\t\tcnt_row[i] = 1\n\t\t\tcnt_col[j] = 1\nprint(n * m - sum(cnt_col) * sum(cnt_row))\n", "(r, c) = map(int, input().strip().split())\nl = []\nR = 0\nC = 0\nz = 0\nC1 = set()\nfor i in range(r):\n\tl.append(input())\n\tif l[i].find('S', 0) == -1:\n\t\tz += 1\n\telse:\n\t\tR += 1\nfor i in range(r):\n\tfor j in range(c):\n\t\tif l[i][j] == 'S':\n\t\t\tC1.add(j)\nC = len(C1)\nprint(r * c - R * C)\n", "(r, c) = map(int, input().split())\ns = []\nfor i in range(r):\n\ts.append(list(input()))\nfor i in range(r):\n\tif s[i].count('S') == 0:\n\t\tfor j in range(c):\n\t\t\ts[i][j] = '0'\nfor j in range(c):\n\tflag = 0\n\tfor i in range(r):\n\t\tif s[i][j] == 'S':\n\t\t\tflag = +1\n\tif flag == 0:\n\t\tfor i in range(r):\n\t\t\ts[i][j] = '0'\nans = 0\nfor i in range(r):\n\tans += s[i].count('0')\nprint(ans)\n", "(row, col) = map(int, input().split())\ntable = [list(map(str, input())) for i in range(row)]\nfor r in range(row):\n\tflag = True\n\tfor c in range(col):\n\t\tif table[r][c] == 'S':\n\t\t\tflag = False\n\t\t\tbreak\n\tif flag:\n\t\tfor c in range(col):\n\t\t\ttable[r][c] = 'e'\nfor c in range(col):\n\tflag = True\n\tfor r in range(row):\n\t\tif table[r][c] == 'S':\n\t\t\tflag = False\n\t\t\tbreak\n\tif flag:\n\t\tfor r in range(row):\n\t\t\ttable[r][c] = 'e'\ncont = 0\nfor r in range(row):\n\tfor c in range(col):\n\t\tif table[r][c] == 'e':\n\t\t\tcont += 1\nprint(cont)\n", "(r, c) = map(int, input().split())\ncake = list((input() for i in range(r)))\nprint(r * c - len([1 for i in cake if 'S' in i]) * len([1 for j in zip(*cake) if 'S' in j]))\n", "(r, c) = [int(x) for x in input().split()]\nfnd = 0\ncols_idx = []\nT = []\nfor i in range(r):\n\tins = list(input())\n\tif 'S' not in ins:\n\t\tfnd += len(ins)\n\telse:\n\t\tT.append(ins)\n\t\tcols_idx.extend([i for (i, val) in enumerate(ins) if val == 'S'])\nfor i in range(c):\n\tif i in cols_idx:\n\t\tcontinue\n\telse:\n\t\tfor j in T:\n\t\t\tj[i] = None\n\t\t\tfnd += 1\nprint(fnd)\n", "(r, c) = map(int, input().split())\nl = []\nfor i in range(r):\n\tw = list(input())\n\tl.append(w)\nm = []\nh = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\tif l[i][j] != 'S':\n\t\t\tt = [i, j]\n\t\t\tm.append(t)\n\t\telse:\n\t\t\th += 1\nif h == 0:\n\tprint(r * c)\nelse:\n\ta = []\n\tq = []\n\tf = max(c, r)\n\tfor i in range(f):\n\t\tcount = 0\n\t\tplus = 0\n\t\tfor j in range(len(m)):\n\t\t\tif m[j][0] == i:\n\t\t\t\tcount += 1\n\t\t\tif m[j][1] == i:\n\t\t\t\tplus += 1\n\t\ta.append(count)\n\t\tq.append(plus)\n\ty = a.count(c)\n\tu = q.count(r)\n\tb = y * u\n\to = y * c + u * r - b\n\tprint(o)\n", "(n, m) = list(map(int, input().split()))\nl = []\nk = 0\nfor _ in range(n):\n\ts = input()\n\tif 'S' not in s:\n\t\tk += 1\n\tl.append(s)\nif k == n:\n\tprint(n * m)\nelse:\n\tk1 = 0\n\tfor i in range(m):\n\t\ts = ''\n\t\tfor j in range(n):\n\t\t\ts += l[j][i]\n\t\tif 'S' not in s:\n\t\t\tk1 += 1\n\tprint(k * m + k1 * n) if k == 0 or k1 == 0 else print(k * m + k1 * n - k * k1)\n", "from itertools import product\n(r, c) = map(int, input().split())\ncake = []\nstrawberries_x = set()\nstrawberries_y = set()\nfor i in range(r):\n\tcake.append(input())\n\tfor j in range(c):\n\t\tif cake[i][j] == 'S':\n\t\t\tstrawberries_x.add(i)\n\t\t\tstrawberries_y.add(j)\ndangerous_spots = len(set(product(strawberries_x, strawberries_y)))\nprint(r * c - dangerous_spots)\n", "from collections import deque\nfrom math import log, sqrt, ceil\n\ndef ii():\n\treturn int(input())\n\ndef si():\n\treturn input()\n\ndef mi():\n\treturn map(int, input().strip().split(' '))\n\ndef li():\n\treturn list(mi())\n(r, c) = mi()\na = []\nb = []\nfor i in range(r):\n\ts = si()\n\tfor j in range(c):\n\t\tif s[j] == 'S':\n\t\t\ta.append(i)\n\t\t\tb.append(j)\nc1 = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\t(f, f1) = (0, 0)\n\t\tif i not in a:\n\t\t\tf = 1\n\t\tif j not in b:\n\t\t\tf1 = 1\n\t\tif f == 1 or f1 == 1:\n\t\t\tc1 += 1\nprint(c1)\n", "(row, col) = map(int, input().split())\ngrid = []\nfor i in range(row):\n\ts = input()\n\tgrid.append(list(s))\nfor i in range(row):\n\tfor j in range(col):\n\t\tif grid[i][j] == 'S':\n\t\t\tbreak\n\telse:\n\t\tgrid[i] = ['X'] * col\nfor j in range(col):\n\tfor i in range(row):\n\t\tif grid[i][j] == 'S':\n\t\t\tbreak\n\telse:\n\t\tfor i in range(row):\n\t\t\tgrid[i][j] = 'X'\nans = 0\nfor line in grid:\n\tans += line.count('X')\nprint(ans)\n", "cake = [int(y) for y in input().split()]\nl = []\neaten = 0\ncolumnCakes = int(cake[0])\nfor var in range(cake[0]):\n\tl.append(input())\nfor var in range(cake[0]):\n\tif l[var] == str('.' * cake[1]):\n\t\teaten += cake[1]\n\t\tcolumnCakes -= 1\nfor var in range(cake[1]):\n\tS = False\n\tfor e in l:\n\t\tif e[var] == 'S':\n\t\t\tS = True\n\t\t\tbreak\n\tif not S:\n\t\teaten += columnCakes\nprint(eaten)\n", "_ = list(map(int, input().split()))\n____ = list()\n____.append([0 for i in range(_[0])])\n____.append([0 for i in range(_[1])])\nfor __ in range(_[0]):\n\t_______ = 0\n\t___ = input()\n\t_________ = 0\n\tfor ________ in range(___.count('S')):\n\t\t_________ = ___[_______:].find('S')\n\t\tif ___ != -1:\n\t\t\t____[1][_________ + _______] = 1\n\t\t\t____[0][__] = 1\n\t\telse:\n\t\t\tbreak\n\t\t_______ += _________ + 1\nprint(____[1].count(0) * _[0] + ____[0].count(0) * _[1] - ____[0].count(0) * ____[1].count(0))\n", "(r, c) = list(map(int, input().split()))\nmatrix = []\nfor i in range(r):\n\tline = list(input())\n\tmatrix.append(line)\nmatrix90 = []\nfor i in range(c):\n\tline = []\n\tfor j in range(r):\n\t\tline.append(matrix[j][i])\n\tmatrix90.append(line)\nCount = Count2 = 0\nfor i in matrix:\n\tif 'S' not in i:\n\t\tCount += 1\nfor i in matrix90:\n\tif 'S' not in i:\n\t\tCount2 += 1\nC = Count * len(matrix[0]) + Count2 * len(matrix90[0]) - Count * Count2\nprint(C)\n", "l = lambda : map(int, input().split())\n(r, c) = l()\nk = [input() for _ in ' ' * r]\nn = 0\n(p, q) = (r, c)\nfor i in range(p):\n\ta = k[i].count('.')\n\tif a == c:\n\t\tr -= 1\n\t\tn += c\n\t\tk[i] = '*' * c\nt = list(zip(*k))\nfor i in range(q):\n\ta = t[i].count('.')\n\tif a == r:\n\t\tn += r\nprint(n)\n", "a = input().split()\nr = int(a[0])\nc = int(a[1])\nl = []\nfor i in range(r):\n\ts = input()\n\tl.append(s)\ns = 0\nfor i in range(r):\n\tif 'S' not in l[i]:\n\t\ts = s + c\np = s // c\nz = 0\nfor i in range(c):\n\tt = 0\n\tfor j in range(r):\n\t\tif l[j][i] == 'S':\n\t\t\tt = 1\n\t\t\tbreak\n\t\telse:\n\t\t\tt = 0\n\tif t == 0:\n\t\tz = z + r - p\nprint(z + s)\n", "(r, c) = map(int, input().split())\na = []\nfor i in range(r):\n\ta.append(input())\nmas = [[False] * c for i in range(r)]\nfor i in range(r):\n\tif 'S' not in a[i]:\n\t\tfor j in range(c):\n\t\t\tmas[i][j] = True\nfor j in range(c):\n\tfind = False\n\tfor i in range(r):\n\t\tif a[i][j] == 'S':\n\t\t\tfind = True\n\t\t\tbreak\n\tif not find:\n\t\tfor i in range(r):\n\t\t\tmas[i][j] = True\nk = 0\nfor i in mas:\n\tk += i.count(True)\nprint(k)\n", "(r, c) = map(int, input().split())\nlis = []\nfor i in range(r):\n\tlis.append(input())\ndicr = {}\ndicc = {}\nfor i in range(r):\n\tfor j in range(c):\n\t\tif lis[i][j] == 'S':\n\t\t\tdicr[i] = 1\n\t\t\tdicc[j] = 1\ncount = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\tif lis[i][j] != 'S':\n\t\t\tif dicr.get(i, 0) == 0 or dicc.get(j, 0) == 0:\n\t\t\t\tcount += 1\nprint(count)\n", "def main():\n\t(r, c) = map(int, input().split())\n\tgrid = [input() for _ in range(r)]\n\trows = [False] * r\n\tcols = [False] * c\n\tfor x in range(r):\n\t\tfor y in range(c):\n\t\t\tif grid[x][y] == 'S':\n\t\t\t\trows[x] = True\n\t\t\t\tcols[y] = True\n\tans = r * c\n\tfor x in range(r):\n\t\tfor y in range(c):\n\t\t\tif rows[x] and cols[y]:\n\t\t\t\tans -= 1\n\tprint(ans)\nmain()\n", "(n, m) = map(int, input().split())\nl1 = []\nl2 = []\nfor i in range(0, n):\n\tl3 = [0] * m\n\tl2.append(l3)\n\ts = input()\n\tl1.append(s)\nfor i in range(0, n):\n\tif 'S' in l1[i]:\n\t\tcontinue\n\telse:\n\t\tfor j in range(0, m):\n\t\t\tl2[i][j] += 1\nfor i in range(0, m):\n\tflag = 0\n\tfor j in range(0, n):\n\t\tif l1[j][i] == 'S':\n\t\t\tflag = 1\n\tif flag == 0:\n\t\tfor j in range(0, n):\n\t\t\tl2[j][i] += 1\nx = 0\nfor item in l2:\n\tx += item.count(0)\nprint(n * m - x)\n", "(r, c) = (int(x) for x in input().split())\ns = []\nn_r = 0\nans = 0\nfor i in range(r):\n\ts.append(input())\n\tif s[i] == '.' * c:\n\t\tn_r += 1\n\t\tans += c\nfor t in map(lambda x: ''.join(x), zip(*s)):\n\tif t == '.' * r:\n\t\tans += r - n_r\nprint(ans)\n", "(rows, columns) = map(int, input().strip().split())\nmatrix = [[0 for x in range(columns)] for y in range(rows)]\nfor i in range(rows):\n\tn = list(input())\n\tfor j in range(len(n)):\n\t\tmatrix[i][j] = n[j]\nk = 0\nfor i in range(rows):\n\tc = 0\n\tfor j in range(columns):\n\t\tif matrix[i][j] != 'S':\n\t\t\tc += 1\n\tif c == columns:\n\t\tfor j in range(columns):\n\t\t\tk += 1\n\t\t\tmatrix[i][j] = 'v'\nfor i in range(columns):\n\tc = 0\n\tfor j in range(rows):\n\t\tif matrix[j][i] != 'S':\n\t\t\tc += 1\n\tif c == rows:\n\t\tfor j in range(rows):\n\t\t\tif matrix[j][i] != 'v':\n\t\t\t\tk += 1\nprint(k)\n", "(r, c) = [int(x) for x in input().split()]\na = [[str(x) for x in input()] for i in range(0, r)]\nmax_cake = 0\nflag = 0\ntemp = 0\nfor i in range(0, r):\n\tcount = 0\n\tfor j in range(0, c):\n\t\tif a[i][j] == '.':\n\t\t\tcount += 1\n\t\tif count == c:\n\t\t\tmax_cake += count\n\t\t\ttemp += 1\nfor j in range(0, c):\n\tcount = 0\n\tfor i in range(0, r):\n\t\tif a[i][j] == '.':\n\t\t\tcount += 1\n\t\tif count == r:\n\t\t\tmax_cake += count\n\t\t\tflag += 1\nfinal = max_cake - flag * temp\nprint(final)\n", "t = input().split()\nS = []\ncount1 = 0\ncount2 = 0\nL = []\nfor i in range(int(t[0])):\n\tS.append(input())\nfor k in range(int(t[1])):\n\tl = ''\n\tfor j in range(int(t[0])):\n\t\tl += S[j][k]\n\tL.append(l)\nfor i in range(int(t[0])):\n\tif 'S' not in S[i]:\n\t\tcount1 += 1\nfor k in range(int(t[1])):\n\tif 'S' not in L[k]:\n\t\tcount2 += 1\na = count1 * int(t[1]) + count2 * int(t[0]) - count1 * count2\nprint(a)\n", "def col(l, c):\n\tb = True\n\tfor i in range(len(l)):\n\t\tif l[i][c] == 'S':\n\t\t\tb = False\n\t\t\tbreak\n\treturn b\nwhile True:\n\ttry:\n\t\tl = []\n\t\t(a, b) = map(int, input().split(' '))\n\t\tfor i in range(a):\n\t\t\tl += [list(input())]\n\t\ts = 0\n\t\t(r, c) = (0, 0)\n\t\tfor i in range(len(l)):\n\t\t\tif 'S' in l[i]:\n\t\t\t\tr += 1\n\t\tfor j in range(len(l[0])):\n\t\t\tif not col(l, j):\n\t\t\t\tc += 1\n\t\t\t\tcontinue\n\t\tprint(a * b - r * c)\n\texcept:\n\t\tbreak\n", "s = input().split()\n(r, c) = (int(s[0]), int(s[1]))\narr = []\nfor i in range(r):\n\ts = input()\n\ttemp = []\n\tfor cc in s:\n\t\ttemp.append(1 if cc == 'S' else 0)\n\tarr.append(temp)\nfor i in range(r):\n\tif not 1 in arr[i]:\n\t\tfor j in range(c):\n\t\t\tif arr[i][j] == 0:\n\t\t\t\tarr[i][j] = 2\na = []\nfor i in range(c):\n\ta.append([arr[0][i]])\nfor i in range(1, r):\n\tfor j in range(c):\n\t\ta[j].append(arr[i][j])\nfor i in range(c):\n\tif not 1 in a[i]:\n\t\tfor j in range(r):\n\t\t\tif a[i][j] == 0:\n\t\t\t\ta[i][j] = 2\nans = 0\nfor i in range(c):\n\tfor j in range(r):\n\t\tans += 1 if a[i][j] == 2 else 0\nprint(ans)\n", "(r, c) = map(int, input().split())\nr_val = [0] + [c] * r\nc_val = [0] + [r] * c\nfor x in range(1, r + 1):\n\tline = input()\n\tfor (i, c) in enumerate(line):\n\t\tif c == 'S':\n\t\t\tr_val[x] = 0\n\t\t\tc_val[i + 1] = 0\ntotal = 0\nfor x in r_val:\n\ttotal += x\n\tr -= min(x, 1)\nfor y in c_val:\n\tif y > 0:\n\t\ttotal += r\nprint(total)\n", "def cake_eater():\n\tsize = input().split()\n\tsize = [int(i) for i in size]\n\tmatrix = []\n\tfor i in range(size[0]):\n\t\tmatrix.append(input())\n\toutput = 0\n\trows = {}\n\tcolumns = {}\n\tfor i in range(len(matrix)):\n\t\tfor j in range(len(matrix[i])):\n\t\t\tif matrix[i][j] == 'S':\n\t\t\t\trows[i] = 1\n\t\t\t\tcolumns[j] = 1\n\tfor i in range(len(matrix)):\n\t\tfor j in range(len(matrix[i])):\n\t\t\tif matrix[i][j] == '.':\n\t\t\t\tif i not in rows or j not in columns:\n\t\t\t\t\toutput += 1\n\t\t\t\t\tcontinue\n\tprint(output)\n\treturn\ncake_eater()\n", "(r, c) = map(int, input().rstrip().split())\nm = [input() for _ in range(r)]\ncm = [[m[i][j] for i in range(r)] for j in range(c)]\nrc = count = 0\nfor i in range(r):\n\tif 'S' not in m[i]:\n\t\tcount += c\n\t\trc += 1\nfor j in range(c):\n\tif 'S' not in cm[j]:\n\t\tcount += r - rc\nprint(count)\n", "(n, m) = map(int, input().split(' '))\nL = [input() for x in range(n)]\nx = set([])\ny = set([])\nfor i in range(n):\n\tfor j in range(m):\n\t\tif L[i][j] == 'S':\n\t\t\tx.add(i)\n\t\t\ty.add(j)\nans = n * (m - len(y)) + m * (n - len(x)) - (m - len(y)) * (n - len(x))\nprint(ans)\n", "(r, c) = map(int, input().split())\nl = [[0] * c] * r\nfor i in range(r):\n\tl[i] = list(input())\ncr = 0\ncc = 0\nfor i in range(r):\n\tx = l[i]\n\tif 'S' not in x:\n\t\tcr += 1\nfor j in range(c):\n\tx = [l[i][j] for i in range(r)]\n\tif 'S' not in x:\n\t\tcc += 1\nans = max(cr * c + cc * r - cr * cc, 0)\nprint(ans)\n", "(a, b) = map(int, input().split(' '))\ncake = []\nfor i in range(a):\n\tcake.append(input())\neat = 0\nfor i in range(a):\n\tif 'S' not in cake[i] and '.' in cake[i]:\n\t\teat += cake[i].count('.')\n\t\tcake[i] = cake[i].replace('.', 'x')\nfor i in range(b):\n\tif 'S' not in [row[i] for row in cake] and '.' in [row[i] for row in cake]:\n\t\teat += [row[i] for row in cake].count('.')\nprint(eat)\n", "(r, c) = map(int, input().split(' '))\nl = []\nc1 = []\nt = 0\nfor i in range(r):\n\tl1 = input()\n\tl1 = list(l1)\n\tif 'S' in l1:\n\t\tfor j in range(len(l1)):\n\t\t\tif l1[j] == 'S':\n\t\t\t\tif j in c1:\n\t\t\t\t\tcontinue\n\t\t\t\telse:\n\t\t\t\t\tc1.append(j)\n\telse:\n\t\tt += 1\nm = c - len(c1)\nn = t\ns = m * r + len(c1) * t\nprint(s)\n", "x = input().split(' ')\n(l, w) = (int(x[0]), int(x[1]))\nlst = []\nfor i in range(l):\n\tx = input()\n\tlst.append([])\n\tfor j in x:\n\t\tlst[i].append(j)\nloc = []\nprint()\nfor i in range(l):\n\tloc.append([])\n\tfor j in range(w):\n\t\tloc[i].append([i, j])\nc = 0\nv = 0\neaten_w = []\nfor i in loc:\n\tfor j in i:\n\t\tif lst[j[0]][j[1]] != 'S':\n\t\t\tc += 1\n\t\t\tif c == w:\n\t\t\t\tfor j in i:\n\t\t\t\t\teaten_w.append(j)\n\tc = 0\nr = 0\np = 0\neaten_l = []\nfor i in range(w):\n\tfor j in range(l):\n\t\td = loc[j][i]\n\t\tif lst[d[0]][d[1]] != 'S':\n\t\t\tr += 1\n\t\t\tif r == l:\n\t\t\t\tfor j in range(l):\n\t\t\t\t\td = loc[j][i]\n\t\t\t\t\teaten_l.append(d)\n\tr = 0\nlast_lst = eaten_w\nfor i in eaten_l:\n\tif i not in last_lst:\n\t\tlast_lst.append(i)\nprint(len(last_lst))\n", "(n, m) = map(int, input().split())\ncount = 0\nr = [False] * n\nc = [False] * m\nfor i in range(n):\n\ts = input()\n\tfor j in range(m):\n\t\tif s[j] == 'S':\n\t\t\tr[i] = True\n\t\t\tc[j] = True\nprint(r.count(False) * m + c.count(False) * n - r.count(False) * c.count(False))\n", "(a, b) = map(int, input().split())\nl = []\ncount = row = 0\nfor i in range(a):\n\tl.append(input())\n\tif 'S' not in l[i]:\n\t\tcount += 1\nfor i in range(b):\n\tcol = 0\n\tfor j in range(a):\n\t\tif l[j][i] == 'S':\n\t\t\tcol += 1\n\tif col == 0:\n\t\trow += 1\nprint(row * a + count * b - count * row)\n", "(r, c) = [int(i) for i in input().split()]\nmass = []\nres1 = 0\nres2 = 0\nfor i in range(r):\n\ts = input()\n\tmass.append(s)\n\tif s.find('S') == -1:\n\t\tres1 += 1\nfor j in range(c):\n\tfor i in range(r):\n\t\tif mass[i][j] == 'S':\n\t\t\tbreak\n\telse:\n\t\tres2 += r - res1\nprint(res1 * c + res2)\n", "(n, d) = input().split()\nn = int(n)\nd = int(d)\nh = [''] * n\ns = 0\nt = d\nfor i in range(n):\n\th[i] = input()\n\tif 'S' not in h[i]:\n\t\ts += 1\nb = [0] * d\nfor i in range(n):\n\tfor j in range(d):\n\t\tif h[i][j] == 'S':\n\t\t\tb[j] = 1\nfor i in range(d):\n\tif b[i] == 1:\n\t\tt -= 1\nprint(s * d + t * n - s * t)\n", "(r, c) = map(int, input().split())\na = []\nfor i in range(r):\n\ta.append(input())\ntotal_s_str = 0\ntotal_s_column = 0\nfor i in range(r):\n\ts_str = 0\n\tfor j in range(c):\n\t\tif a[i][j] != 'S':\n\t\t\ts_str += 1\n\t\t\tif s_str == c:\n\t\t\t\ttotal_s_str += c\n\t\telse:\n\t\t\ts_str = 0\nfor j in range(c):\n\ts_column = 0\n\tfor i in range(r):\n\t\tif a[i][j] != 'S':\n\t\t\ts_column += 1\n\t\t\tif s_column == r:\n\t\t\t\ttotal_s_column += r\n\t\telse:\n\t\t\ts_column = 0\nprint(total_s_str + (total_s_column - total_s_str // c * (total_s_column // r)))\n", "(r, c) = map(int, input().split())\na = [list(input()) for i in range(r)]\nr1 = r - sum(('S' in line for line in a))\nl2 = list(map(list, zip(*a)))\nc1 = c - sum(('S' in line for line in l2))\nprint(c1 * r + r1 * c - r1 * c1)\n", "from sys import stdin\nlines = [x.rstrip() for x in stdin.readlines()]\n(r, c) = lines[0].split(maxsplit=1)\ngrid = lines[1:]\nnum_rows = len(grid)\nnum_cols = len(grid[0])\nsafe_rows = [(i, j) for j in range(num_cols) for (i, row) in enumerate(grid) if 'S' not in row]\ncols = [''.join([g[j] for g in grid]) for j in range(num_cols)]\nsafe_cols = [(i, j) for i in range(num_rows) for (j, col) in enumerate(cols) if 'S' not in col]\nprint(len(set(safe_cols + safe_rows)))\n", "(r, c) = map(int, input().split())\nrow = set()\ncol = set()\narr = []\nfor j in range(r):\n\ttemp = list(input())\n\tz = []\n\tfor (i, item) in enumerate(temp):\n\t\tif item == 'S':\n\t\t\trow.add(j)\n\t\t\tcol.add(i)\n\t\t\tz.append(-1)\n\t\telse:\n\t\t\tz.append(0)\n\tarr.append(z)\nans = 0\nfor i in range(r):\n\tif i not in row:\n\t\tfor j in range(c):\n\t\t\tif arr[i][j] == 0:\n\t\t\t\tarr[i][j] = 1\n\t\t\t\tans += 1\nfor j in range(c):\n\tif j not in col:\n\t\tfor i in range(r):\n\t\t\tif arr[i][j] == 0:\n\t\t\t\tarr[i][j] = 1\n\t\t\t\tans += 1\nprint(ans)\n", "area = [int(i) for i in input().split(' ')]\n(rows, coleat, cells) = ([], 0, 0)\nfor row in range(area[0]):\n\trows.append(input())\nfor col in range(area[1]):\n\ttemp = 0\n\tfor row1 in range(area[0]):\n\t\tif rows[row1][col] == 'S':\n\t\t\tbreak\n\t\telse:\n\t\t\ttemp += 1\n\tif temp == area[0]:\n\t\tcells += temp\n\t\tcoleat += 1\nfor row2 in range(area[0]):\n\tif 'S' not in rows[row2]:\n\t\tcells += area[1] - coleat\nprint(cells)\n", "(r, c) = list(map(int, input().split()))\no = []\npiso = []\nmal = 0\nbien = 0\nfor i in range(r):\n\to.append(list(input()))\nj = 0\nk = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\tif o[i][j] == 'S':\n\t\t\tmal += 1\n\t\t\tbreak\nfor i in range(c):\n\tfor j in range(r):\n\t\tif o[j][i] == 'S':\n\t\t\tbien += 1\n\t\t\tbreak\nprint(r * c - mal * bien)\n", "def main():\n\t(r, c) = map(int, input().split())\n\tcake = [input() for _ in range(r)]\n\tneigh = []\n\tfor y in range(r):\n\t\tfor x in range(c):\n\t\t\tif not 'S' in cake[y]:\n\t\t\t\tneigh.append(tuple(range(y * c, y * c + c)))\n\t\t\tif all(('S' != _[x] for _ in cake)):\n\t\t\t\tneigh.append(tuple(range(x, r * c, c)))\n\tfield = [_ == '.' for s in cake for _ in s]\n\tstart = sum(field)\n\tif any(neigh):\n\t\twhile True:\n\t\t\tnn = max(neigh, key=lambda e: sum((field[_] for _ in e)))\n\t\t\tif not sum((field[_] for _ in nn)):\n\t\t\t\tbreak\n\t\t\tfor i in nn:\n\t\t\t\tfield[i] = False\n\tprint(start - sum(field))\nmain()\n", "(n, m) = map(int, input().split())\ns_row = []\ns_col = []\ncake = []\nfor i in range(n):\n\tx = [i for i in input()]\n\tcake.append(x)\n\tfor j in range(len(x)):\n\t\tif x[j] == 'S':\n\t\t\ts_row.append(i)\n\t\t\ts_col.append(j)\ncount = 0\nrem = 0\nfor i in range(n):\n\tif i not in s_row:\n\t\tcount += m\n\t\trem += 1\nfor j in range(m):\n\tif j not in s_col:\n\t\tcount += n - rem\nprint(count)\n", "(a, b) = map(int, input().split())\nrow = []\ncolumn = []\nfor i in range(a):\n\tx = list(str(input()))\n\tif 'S' in x and i + 1 not in row:\n\t\trow.append(i + 1)\n\tfor j in range(len(x)):\n\t\tif x[j] == 'S' and j + 1 not in column:\n\t\t\tcolumn.append(j + 1)\nprint(a * b - len(row) * len(column))\n", "(a, b) = map(int, input().split())\ny = [0] * a\nx = [0] * b\nfor i in range(a):\n\tf = input()\n\tif f.count('S') > 0:\n\t\ty[i] = 1\n\tfor j in range(len(f)):\n\t\tif f[j].count('S') > 0:\n\t\t\tx[j] = 1\nq = 0\ncc = 0\nfor i in range(b):\n\tif x[i] != 1:\n\t\tq += a\n\t\tcc += 1\nfor i in range(a):\n\tif y[i] != 1:\n\t\tq += b - cc\nprint(q)\n", "(n, m) = map(int, input().split())\ngrid = [input() for line in range(n)]\nrows = len([line for line in grid if line == '.' * m])\ncols = len([True for col in range(m) if len([row[col] for row in grid if row[col] == '.']) == n])\nprint(rows * m + cols * n - rows * cols)\n", "(n, m) = map(int, input().split())\na = []\nfor i in range(n):\n\ta.append(list(input()))\ns = 0\ns1 = 0\nfor i in range(n):\n\tcount = 0\n\tfor j in range(m):\n\t\tif a[i][j] == '.':\n\t\t\tcount += 1\n\tif count == m:\n\t\ts += m\n\t\ts1 += 1\nfor i in range(m):\n\tcount = 0\n\tfor j in range(n):\n\t\tif a[j][i] == '.':\n\t\t\tcount += 1\n\tif count == n:\n\t\ts += n - s1\nprint(s)\n", "(r, c) = map(int, input().split())\nblockedCols = set()\nblockedRows = set()\nmatrix = []\nfor i in range(r):\n\trow = input()\n\tmatrix.append(row)\n\tfor j in range(c):\n\t\tif row[j] == 'S':\n\t\t\tblockedRows.add(i)\n\t\t\tblockedCols.add(j)\nres = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\tif i not in blockedRows or j not in blockedCols:\n\t\t\tres += 1\nprint(res)\n", "(row, col) = map(int, input().split())\nlst = []\ncr = 0\ncc = 0\nfor _ in range(row):\n\ts = input()\n\tif 'S' not in s:\n\t\tcr += 1\n\tlst.append(s)\nfor i in range(col):\n\tif 'S' not in [r[i] for r in lst]:\n\t\tcc += 1\nprint(row * cc + col * cr - cc * cr)\n", "(x, y) = map(int, input().split())\nl = 0\nq = []\nfor i in range(x):\n\ta = input()\n\tif a.count('S') > 0:\n\t\tq.append(a)\n\telse:\n\t\tl = l + len(a)\nf = 0\nfor i in range(y):\n\tfor j in range(len(q)):\n\t\tif q[j][i] == 'S':\n\t\t\tf = 1\n\tif f != 1:\n\t\tl = l + len(q)\n\tf = 0\nprint(l)\n", "import math\ninput1 = list(map(int, input().split()))\nr = int(input1[0])\nc = int(input1[1])\ngrid = []\ntotal_s = 0\nrows_eaten = 0\nfor row in range(0, r):\n\tnew_row = []\n\trow_contains_s = False\n\tfor char in input():\n\t\tnew_row.append(char)\n\t\tif char.lower() == 's':\n\t\t\trow_contains_s = True\n\tif row_contains_s == False:\n\t\ttotal_s += c\n\t\trows_eaten += 1\n\t\tnew_row = []\n\t\tfor char in range(0, c):\n\t\t\tnew_row.append('x')\n\t\tgrid.append(new_row)\n\telse:\n\t\tgrid.append(new_row)\nfor col in range(0, c):\n\tcol_contains_s = False\n\tnumber_of_eaten_already = 0\n\tfor row in range(0, r):\n\t\tchar = grid[row][col]\n\t\tif char.lower() == 's':\n\t\t\tcol_contains_s = True\n\t\tif char.lower() == 'x':\n\t\t\tnumber_of_eaten_already += 1\n\tif col_contains_s == False:\n\t\ttotal_s += r - number_of_eaten_already\nprint(total_s)\n", "size = list(map(int, input().split(' ')))\nevil_strawberrys_rows = set()\nevil_strawberrys_columns = set()\nfor i in range(size[0]):\n\trow = input()\n\tfor j in range(size[1]):\n\t\tif row[j] == 'S':\n\t\t\tevil_strawberrys_rows.add(i)\n\t\t\tevil_strawberrys_columns.add(j)\nanswer = size[0] * size[1] - len(evil_strawberrys_rows) * len(evil_strawberrys_columns)\nprint(answer)\n", "(r, c) = map(int, input().split())\ncnt = 0\na = []\nfor i in range(r):\n\ts = input()\n\ta.append(s)\nkhordeshode = [[False for i in range(c)] for j in range(r)]\nfor i in range(r):\n\tif not 'S' in a[i]:\n\t\tfor j in range(c):\n\t\t\tif not khordeshode[i][j]:\n\t\t\t\tcnt += 1\n\t\t\t\tkhordeshode[i][j] = True\nfor i in range(c):\n\thast = False\n\tfor j in range(r):\n\t\tif a[j][i] == 'S':\n\t\t\thast = True\n\t\t\tbreak\n\tif not hast:\n\t\tfor j in range(r):\n\t\t\tif not khordeshode[j][i]:\n\t\t\t\tcnt += 1\n\t\t\t\tkhordeshode[j][i] = True\nprint(cnt)\n", "(r, c) = list(map(int, input().split()))\na = []\nfor i in range(r):\n\ta.append(input())\nx = r\nfor i in range(r):\n\tfor j in range(c):\n\t\tif a[i][j] == 'S':\n\t\t\tx -= 1\n\t\t\tbreak\ny = c\nfor j in range(c):\n\tfor i in range(r):\n\t\tif a[i][j] == 'S':\n\t\t\ty -= 1\n\t\t\tbreak\nprint(x * c + r * y - x * y)\n", "(X, Y) = map(int, input().split())\neat = 0\nate = 0\nLanes = []\nfor a in range(X):\n\tLane = list(input())\n\tLanes.append(Lane)\n\tif 'S' not in Lane:\n\t\teat += Y\n\t\tate += 1\nfor b in range(Y):\n\tstat = 0\n\tfor c in range(X):\n\t\tif Lanes[c][b] == 'S':\n\t\t\tstat = 1\n\tif stat == 0:\n\t\teat += X - ate\nprint(eat)\n", "(r, c) = map(int, input().split())\nall_seq = []\ncount_row_with_out_s = 0\ncount_col_with_out_s = 0\nfor i in range(r):\n\trow_input = input()\n\tall_seq.append(row_input)\nfor row in all_seq:\n\tif 'S' not in row:\n\t\tcount_row_with_out_s += 1\nfor col in range(c):\n\tflag = True\n\tfor row in range(r):\n\t\tif all_seq[row][col] == 'S':\n\t\t\tflag = False\n\t\t\tbreak\n\tif flag:\n\t\tcount_col_with_out_s += 1\neatable_row_cells = count_row_with_out_s * c\neatable_col_cells = count_col_with_out_s * r - count_col_with_out_s * count_row_with_out_s\nprint(eatable_row_cells + eatable_col_cells)\n", "(n, m) = map(int, input().split())\ncake = [input() for i in range(n)]\nA = [[1 for j in range(m)] for i in range(n)]\nfor i in range(n):\n\tfor j in range(m):\n\t\tif cake[i][j] == 'S':\n\t\t\tA[i][j] = 2\nc = 0\nfor i in range(n):\n\tk = 0\n\tfor j in range(m):\n\t\tif A[i][j] == 1 and k >= 0:\n\t\t\tk += 1\n\t\telif A[i][j] == 2:\n\t\t\tk = -1\n\tif k >= 0:\n\t\tc += k\n\t\tfor j in range(m):\n\t\t\tA[i][j] = 0\nfor j in range(m):\n\tk = 0\n\tfor i in range(n):\n\t\tif A[i][j] == 1 and k >= 0:\n\t\t\tk += 1\n\t\telif A[i][j] == 2:\n\t\t\tk = -1\n\tif k >= 0:\n\t\tc += k\n\t\tfor i in range(n):\n\t\t\tA[i][j] = 0\nprint(c)\n", "(r, c) = map(int, input().split())\nstrawbery = []\nfor i in range(r):\n\tl = input()\n\tfor j in range(c):\n\t\tif l[j] == 'S':\n\t\t\tstrawbery.append((i, j))\nhor = len({x for (x, y) in strawbery})\nvert = len({x for (y, x) in strawbery})\neaten_hor = (r - hor) * c\neaten_ver = (c - vert) * hor\nprint(eaten_hor + eaten_ver)\n", "(n, m) = input().split()\nm = int(m)\ns = ''\nans = 0\nfor i in range(int(n)):\n\ttemp = str(input())\n\tif 'S' not in temp:\n\t\tans = ans + m\n\t\ttemp = ''\n\ts = s + temp\nfor j in range(int(m)):\n\ttemp = ''\n\twhile j < len(s):\n\t\ttemp = temp + s[j]\n\t\tj = j + int(m)\n\tif 'S' not in temp:\n\t\tans = ans + len(temp)\nprint(ans)\n", "(r, c) = map(int, input().split())\ngrid = [list(input()) for _ in range(r)]\n(rows, cols) = (set(), set())\nfor i in range(r):\n\tfor j in range(c):\n\t\tif grid[i][j] == 'S':\n\t\t\trows.add(i)\n\t\t\tcols.add(j)\nprint(r * c - len(cols) * len(rows))\n", "(r, c) = map(int, input().split())\nrow = set()\ncol = set()\nfor i in range(r):\n\tt = input()\n\tfor j in range(c):\n\t\tif t[j] == 'S':\n\t\t\trow.add(i)\n\t\t\tcol.add(j)\nprint(r * c - len(row) * len(col))\n", "(n, k) = list(map(int, input().split()))\n(m, o) = ([], [])\nfor i in range(n):\n\tc = list(input())\n\tfor j in range(k):\n\t\tif c[j] == 'S':\n\t\t\tm.append(i)\n\t\t\to.append(j)\ne = len(set(m)) * len(set(o))\nprint(n * k - e)\n", "import math\nimport sys\nimport collections\n\ndef getdict(n):\n\td = {}\n\tif type(n) is list:\n\t\tfor i in n:\n\t\t\tif i in d:\n\t\t\t\td[i] += 1\n\t\t\telse:\n\t\t\t\td[i] = 1\n\telse:\n\t\tfor i in range(n):\n\t\t\tt = ii()\n\t\t\tif t in d:\n\t\t\t\td[t] += 1\n\t\t\telse:\n\t\t\t\td[t] = 1\n\treturn d\n\ndef cdiv(n, k):\n\treturn n // k + (n % k != 0)\n\ndef ii():\n\treturn int(input())\n\ndef mi():\n\treturn map(int, input().split())\n\ndef li():\n\treturn list(map(int, input().split()))\n\ndef lcm(a, b):\n\treturn abs(a * b) // math.gcd(a, b)\n(n, m) = mi()\na = []\nfor i in range(n):\n\ta.append(input())\nr = c = 0\nfor i in range(n):\n\tif 'S' not in a[i]:\n\t\tr += 1\nfor i in range(m):\n\tif all((a[j][i] == '.' for j in range(n))):\n\t\tc += 1\nprint(r * m + c * n - r * c)\n", "(n, m) = map(int, input().split())\nl = [input() for i in range(n)]\nr = 0\ns = 0\nfor i in range(n):\n\tif set(l[i]) == {'.'}:\n\t\tr += 1\nfor i in range(m):\n\tse = set(l[0][i])\n\tfor j in range(n):\n\t\tse |= set(l[j][i])\n\tif se == {'.'}:\n\t\ts += 1\nprint(r * m + s * n - s * r)\n", "(r, c) = map(int, input().split())\ncake = []\ncc = [True for i in range(c)]\ncr = [True for i in range(r)]\nt = 0\nfor i in range(r):\n\tcake.append(input())\nfor row in range(r):\n\tfor col in range(c):\n\t\tif cake[row][col] == 'S':\n\t\t\tcc[col] = False\n\t\t\tcr[row] = False\nfor i in range(r):\n\tfor j in range(c):\n\t\tif cc[j] or cr[i]:\n\t\t\tt += 1\nprint(t)\n", "(a, b) = map(int, input().split())\n(s, p) = (0, [[0] * b for i in range(a)])\nfor i in range(a):\n\tt = input()\n\tif 'S' in t:\n\t\tfor j in range(b):\n\t\t\tp[i][j] |= 1\n\t\t\tif t[j] == 'S':\n\t\t\t\tfor k in range(a):\n\t\t\t\t\tp[k][j] |= 2\nfor i in range(a):\n\ts += p[i].count(3)\nprint(a * b - s)\n", "(r, c) = map(int, input().split())\ngrid = [input() for _ in range(r)]\nevilr = sum((any((k == 'S' for k in row)) for row in grid))\nevilc = sum((any((k == 'S' for k in col)) for col in zip(*grid)))\nprint(r * c - evilr * evilc)\n", "(n, m) = map(int, input().split())\nz = []\nfor i in range(n):\n\tl = list(input())\n\tz.append(l)\ncnt = 0\nfor i in z:\n\tif 'S' not in i:\n\t\tcnt += len(i)\n\t\tfor j in range(len(i)):\n\t\t\ti[j] = '0'\nh = []\nfor a in range(m):\n\tk = []\n\tfor b in range(n):\n\t\tk.append(z[b][a])\n\th.append(k)\nfor i in h:\n\tif 'S' not in i:\n\t\tcnt += i.count('.')\nprint(cnt)\n", "(n, m) = map(int, input().split())\na = [list(input()) for i in range(n)]\n(rows, columns) = (0, 0)\nfor i in range(n):\n\tif 'S' not in a[i]:\n\t\tfor j in range(m):\n\t\t\ta[i][j] = 'A'\nfor i in range(m):\n\tif 'S' not in ''.join([a[j][i] for j in range(n)]):\n\t\tfor j in range(n):\n\t\t\ta[j][i] = 'A'\nprint(''.join([''.join(i[:]) for i in a]).count('A'))\n", "(r, c) = list(map(int, input().split()))\nrs = [True] * r\ncs = [True] * c\nfor i in range(r):\n\ts = input()\n\tfor j in range(c):\n\t\tif s[j] == 'S':\n\t\t\trs[i] = False\n\t\t\tcs[j] = False\nans = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\tans += rs[i] or cs[j]\nprint(ans)\n", "[r, c] = [int(i) for i in input().split()]\ncake = []\nfakecake = []\nfor x in range(r):\n\ts = input()\n\tcake.append(s)\n\ttmp = []\n\tfor y in range(c):\n\t\ttmp.append(0)\n\tfakecake.append(tmp)\nfor a in range(r):\n\tevil = 0\n\tfor b in range(c):\n\t\tif cake[a][b] == 'S':\n\t\t\tevil = 1\n\t\t\tbreak\n\tif evil == 0:\n\t\tfor h in range(c):\n\t\t\tfakecake[a][h] = 1\nfor g in range(c):\n\tevil2 = 0\n\tfor h in range(r):\n\t\tif cake[h][g] == 'S':\n\t\t\tevil2 = 1\n\t\t\tbreak\n\tif evil2 == 0:\n\t\tfor k in range(r):\n\t\t\tfakecake[k][g] = 1\nans = 0\nfor e in range(r):\n\tfor f in range(c):\n\t\tif fakecake[e][f] == 1:\n\t\t\tans += 1\nprint(ans)\n", "(r, c) = list(map(int, input().split()))\nm = list()\nans = 0\nfor _ in range(r):\n\tm.append(input())\nans = sum((c for i in range(r) if 'S' not in m[i]))\nfor j in range(c):\n\tclean = True\n\tfor i in range(r):\n\t\tif m[i][j] == 'S':\n\t\t\tclean = False\n\t\t\tbreak\n\tif clean:\n\t\tans += r\n\t\tans += sum((-1 for i in range(r) if 'S' not in m[i]))\nprint(ans)\n", "(r, c) = map(int, input().split())\na = []\nw = 0\ny = 0\nfor i in range(r):\n\ts = input()\n\tif s.find('S') == -1:\n\t\tw += c\n\t\ty += 1\n\tb = []\n\tfor j in range(c):\n\t\tb.append(s[j])\n\ta.append(b[:])\nfor i in range(c):\n\tx = 0\n\tfor j in range(r):\n\t\tif a[j][i] == 'S':\n\t\t\tx = 1\n\tif x == 0:\n\t\tw += r - y\nprint(w)\n", "(r, c) = map(int, input().split())\nl1 = [input() for i in range(r)]\n(l, c1, c2) = ([], 0, 0)\nfor i in range(r):\n\tif 'S' in l1[i]:\n\t\tc1 += 1\nfor j in range(c):\n\tfor i in range(r):\n\t\tif l1[i][j] == 'S':\n\t\t\tc2 += 1\n\t\t\tbreak\nprint(c * (r - c1) + r * (c - c2) - (r - c1) * (c - c2))\n", "import sys\nrc = [int(x) for x in sys.stdin.readline().split()]\nresult = 0\ncol = []\nrow = []\nccol = 0\nfor i in range(rc[0]):\n\tt = list(sys.stdin.readline())\n\tfor j in range(len(t) - 1):\n\t\tif t[j] == 'S':\n\t\t\tccol += 1\n\t\t\tcol.append(j)\n\tif ccol > 0:\n\t\trow.append(i)\n\t\tccol = 0\ncol = list(set(col))\ncol.sort()\nlr = len(row)\nlc = len(col)\nif lc == 0 and lr == 0:\n\tprint(rc[0] * rc[1])\n\texit()\nc = 0\ni = 0\ncnt = 0\nwhile c < rc[0]:\n\tif row[i] == c:\n\t\tif i < lr - 1:\n\t\t\ti += 1\n\telse:\n\t\tcnt += 1\n\t\tresult += rc[1]\n\tc += 1\nd = 0\nj = 0\nwhile d < rc[1]:\n\tif col[j] == d:\n\t\tif j < lc - 1:\n\t\t\tj += 1\n\telse:\n\t\tresult += rc[0] - cnt\n\td += 1\nprint(result)\n", "(a, b) = map(int, input().split())\n(z, w, q) = ([], 0, 0)\nfor i in range(a):\n\tl = list(input())\n\tz.append(l)\n\tif l.count('S') == 0:\n\t\tw += 1\nfor i in range(len(z[0])):\n\te = ''\n\tfor j in range(len(z)):\n\t\te += z[j][i]\n\tif e.count('S') == 0:\n\t\tq += a - w\nprint(w * b + q)\n", "(n, m) = map(int, input().split())\nx = []\ny = ['n'] * m\n(b, c, d, e) = (0, 0, 0, 0)\nfor i in range(n):\n\tx += [list(str(input()))]\nfor j in range(n):\n\tfor k in range(m):\n\t\tif x[j][k] == '.':\n\t\t\tb += 1\n\t\tif b == m:\n\t\t\tc += m\n\t\t\tx[j] = y\n\tb = 0\nfor j in range(m):\n\tfor k in range(n):\n\t\tif x[k][j] == '.':\n\t\t\td += 1\n\t\telif x[k][j] == 'n':\n\t\t\te += 1\n\t\tif d + e == n:\n\t\t\tc += d\n\td = 0\n\te = 0\nprint(c)\n", "(r, c) = [int(x) for x in input().split()]\nrow = [0 for i in range(r)]\ncol = [0 for i in range(c)]\nfor i in range(r):\n\ts = input()\n\tfor j in range(c):\n\t\tif s[j] == 'S':\n\t\t\trow[i] = 1\n\t\t\tcol[j] = 1\ncnt = 0\nfor i in range(r):\n\tfor j in range(c):\n\t\tif row[i] == 0 or col[j] == 0:\n\t\t\tcnt += 1\nprint(cnt)\n", "temp = [int(x) for x in input().split()]\nr = temp[0]\nc = temp[1]\ng = []\nfor i in range(r):\n\tg.append(input())\nchecked = [[True for x in range(c)] for x in range(r)]\nfor i in range(r):\n\tif 'S' in g[i]:\n\t\tfor j in range(c):\n\t\t\tchecked[i][j] = False\n\t\tx = g[i].index('S')\nfor i in range(c):\n\tbool = False\n\tfor j in range(r):\n\t\tif g[j][i] == 'S':\n\t\t\tbool = True\n\t\t\tbreak\n\tif not bool:\n\t\tfor k in range(r):\n\t\t\tchecked[k][i] = True\nresult = 0\nfor x in checked:\n\tresult += x.count(True)\nprint(result)\n", "(a, b) = map(int, input().split())\nl = []\nc = r = 0\nfor _ in range(a):\n\tk = list(input())\n\tl.append(k)\ny = []\nfor i in range(a):\n\tif l[i].count('.') == b:\n\t\tc += b\n\telse:\n\t\ty.append(l[i])\nif len(y) == 0:\n\tprint(c)\n\texit()\nl2 = [[row[i] for row in y] for i in range(len(y[0]))]\nfor i in l2:\n\tif i.count('.') == len(i):\n\t\tr += len(i)\nprint(c + r)\n", "(r, c) = map(int, input().split())\ncells = 0\neaten = 0\ncolumns = [-1] * c\nfor i in range(r):\n\tstrawberry = 0\n\tleft_ind = 0\n\tline = input()\n\tfound = line.find('S', left_ind)\n\twhile found != -1:\n\t\tcolumns[found] = 1\n\t\tleft_ind = found + 1\n\t\tfound = line.find('S', left_ind)\n\t\tstrawberry += 1\n\tif strawberry == 0:\n\t\teaten += 1\nprint(eaten * c + (c - columns.count(1)) * (r - eaten))\n", "b = [int(b) for b in input().split()]\nr = b[0]\nc = b[1]\ne = []\nfor i in range(b[0]):\n\td = [d for d in input()]\n\te.append(d)\nsumr = 0\nsumc = 0\nfor j in range(c):\n\tfor i in range(r):\n\t\tk = 0\n\t\tif e[i][j] == 'S':\n\t\t\tk = 1\n\t\t\tbreak\n\tif k == 0:\n\t\tsumc = sumc + 1\nfor i in range(r):\n\tfor j in range(c):\n\t\tq = 0\n\t\tif e[i][j] == 'S':\n\t\t\tq = 1\n\t\t\tbreak\n\tif q == 0:\n\t\tsumr = sumr + 1\nprint(sumc * r + sumr * c - sumr * sumc)\n", "ar = []\nfor i in input().split(' '):\n\tar.append(int(i))\nmatrix = [[0 for col in range(ar[1])] for row in range(ar[0])]\ncount = 0\nrow_totals = []\nfor i in range(ar[0]):\n\ttemp = input()\n\tch = 0\n\tfor j in range(len(temp)):\n\t\tif temp[j] == 'S':\n\t\t\tmatrix[i][j] = 1\n\t\t\tch = 1\n\tif ch == 0:\n\t\trow_totals.append(0)\n\telse:\n\t\trow_totals.append(1)\ncol_totals = [sum(x) for x in zip(*matrix)]\nfor i in range(len(matrix)):\n\tfor j in range(len(matrix[i])):\n\t\tif row_totals[i] == 0 or col_totals[j] == 0:\n\t\t\tcount = count + 1\nprint(count)\n", "from operator import itemgetter\n(r, c) = map(int, input().split())\nfield = [input() for i in range(r)]\nnum = r * c\nfieldr = [0] * r\nfieldc = [0] * c\nfor i in range(r):\n\tfor j in range(c):\n\t\tif field[i][j] == 'S':\n\t\t\tfieldr[i] = 1\n\t\t\tfieldc[j] = 1\n\t\t\tnum -= 1\nfor i in range(r):\n\tfor j in range(c):\n\t\tif field[i][j] != 'S':\n\t\t\tif fieldr[i] == fieldc[j] and fieldr[i] == 1:\n\t\t\t\tnum -= 1\nprint(num)\n", "(r, c) = list(map(int, input().split()))\n(row, col) = ([], [])\nfor i in range(r):\n\tgrid_row = input()\n\tfor (j, ch) in enumerate(grid_row):\n\t\tif ch == 'S':\n\t\t\trow.append(i)\n\t\t\tcol.append(j)\nrow = len(set(row))\ncol = len(set(col))\neat_row = r - row\neat_col = c - col\neatable = eat_row * c + eat_col * r - eat_col * eat_row\nprint(eatable)\n", "(r, c) = [int(i) for i in input().split()]\n(evilStrawberryColum, evilStrawberryRow, cakeStrings) = (set(), set(), [])\nfor i in range(0, r):\n\tcakeStrings.append(input())\n\tif cakeStrings[i].count('S'):\n\t\t[(evilStrawberryRow.add(i), evilStrawberryColum.add(j)) for j in range(0, c) if cakeStrings[i][j] == 'S']\npieces = r * c - len(evilStrawberryRow) * len(evilStrawberryColum)\nprint(pieces)\n", "from sys import stdin, stdout\nimport math\nfrom itertools import permutations, combinations\nfrom collections import defaultdict\nfrom bisect import bisect_left\n\ndef L():\n\treturn list(map(int, stdin.readline().split()))\n\ndef In():\n\treturn map(int, stdin.readline().split())\n\ndef I():\n\treturn int(stdin.readline())\nP = 1000000007\n(n, m) = In()\narr = [0 for i in range(m)]\nc = 0\nfor i in range(n):\n\ts = input()\n\tif s == '.' * m:\n\t\tc += m\n\telse:\n\t\tfor i in range(m):\n\t\t\tif s[i] == '.':\n\t\t\t\tarr[i] += 1\ntemp = c\nfor i in range(m):\n\tif arr[i] == n - temp // m:\n\t\tc += arr[i]\nprint(c)\n", "(r, c) = [int(num) for num in input().split(' ')]\nmap = []\nfor i in range(r):\n\trow = [ch for ch in input()]\n\tmap.append(row)\nans = 0\nfor i in range(r):\n\tif 'S' not in map[i]:\n\t\tfor j in range(c):\n\t\t\tif map[i][j] == '.':\n\t\t\t\tmap[i][j] = '*'\n\t\t\t\tans += 1\nfor i in range(c):\n\tcnt = 0\n\tisFind = False\n\tfor j in range(r):\n\t\tif map[j][i] == 'S':\n\t\t\tisFind = True\n\t\t\tbreak\n\t\tif map[j][i] == '.':\n\t\t\tcnt += 1\n\tif isFind == False:\n\t\tans += cnt\nprint(ans)\n", "(r, c) = map(int, input().split())\ncake = []\nfor i in range(r):\n\tcake.append(input())\nnal = 0\nnar = 0\nrows = {i: [] for i in range(c)}\nfor i in cake:\n\tfor j in range(c):\n\t\trows[j].append(i[j])\nfor i in cake:\n\tif 'S' in i:\n\t\tnal += 1\nfor i in rows.values():\n\tif 'S' in i:\n\t\tnar += 1\nprint(r * c - nal * nar)\n", "(r, c) = map(int, input().split())\nl = list()\nans = set()\nresult = 0\nfor i in range(r):\n\tl.append(list(input()))\nfor i in range(r):\n\tif 'S' in l[i]:\n\t\tk = 'Do Nothing'\n\telse:\n\t\tresult += c\n\t\tfor j in range(c):\n\t\t\tans.add(str(i) + ' ' + str(j))\nfor i in range(c):\n\tcnt = 0\n\tfor j in range(r):\n\t\tif l[j][i] == 'S':\n\t\t\tbreak\n\t\tcnt += 1\n\tif cnt == r:\n\t\tfor j in range(r):\n\t\t\ttemp = str(j) + ' ' + str(i)\n\t\t\tif temp not in ans:\n\t\t\t\tresult += 1\nprint(result)\n"]

difficulty: EASY

source: codeforces

raw_problem:
A. Cakeminator

time limit per test
1 second

memory limit per test
256 megabytes

input
standard input

output
standard output

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:

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

question:
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](1.png) 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](2.png)  ![image](3.png)  ![image](4.png)

skill_types: ['Complete search']

image_tags: Map Map Map Map

data_split: test