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.

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 the maximum number of cake cells that the cakeminator can eat.

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

#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int r, c, cr = 0, cc = 0;
    cin >> r >> c;

    char arr[r][c];

    for (int i = 0; i < r; ++i) {
        for (int j = 0; j < c; ++j) {
            cin >> arr[i][j];
        }
    }

    for (int i = 0; i < r; ++i) {
        bool n_s = true;
        for (int j = 0; j < c; ++j) {
            if (arr[i][j] == 'S') {
                n_s = false;
                break;
            }
        }

        if (n_s) {
            ++cc;
        }
    }

    for (int j = 0; j < c; ++j) {
        bool n_s = true;
        for (int i = 0; i < r; ++i) {
            if (arr[i][j] == 'S') {
                n_s = false;
                break;
            }
        }

        if (n_s) {
            ++cr;
        }
    }

    cout << (cr * r + cc * c) - (cc && cr ? cr * cc : 0) << "\n";
}

#include <iostream>

using namespace std;

int main()
{
    int r, c, ans, br = 0, bc = 0;
    cin >> r >> c;
    string s[r];
    bool row, columns[c] = {0};
    for(int i = 0; i < r; i++) {
        cin >> s[i];
    }
    for(int i = 0; i < r; i++) {
        row = true;
        for(int j = 0; j < c; j++) {
            if(row && s[i][j] == 'S') {
                br++;
                row = false;
            }
            if(columns[j] == 0 && s[i][j] == 'S') {
                bc++;
                columns[j] = 1;
            }
        }
    }
    ans = (r * c) - (br * bc);
    cout << ans;
    return 0;
}

/*

Author: Saad Ahmed Sadi.
Ruet CSE 11.
Date: 07-04-2014

*/

#include<iostream>
#include<string>
#include<stdio.h>
#include<sstream>
#include<algorithm>
using namespace std;

int main()
{
    int r,c,i,j;
    cin>>r>>c;
    char s[r+10][c+10];

    for(i=0; i<r; i++)
    {
        for(j=0; j<c; j++)
        {
            cin>>s[i][j];
        }
    }
    int sum=0,count;
    for(i=0; i<r; i++)
    {
        count = 0;
        for(j=0; j<c; j++)
        {
            if(s[i][j]!='S')
            {
                if(s[i][j]!='p'){
                count++;
                s[i][j]='p';
                }
            }
            else
            {
                count=0;
                for(int k=0; k<j; k++)
                {
                    s[i][k]='.';
                }
                break;
            }

        }
        sum+=count;
    }
    //cout<<sum<<endl;

    for(i=0; i<c; i++)
    {
        count=0;
        for(j=0; j<r; j++)
        {
            if(s[j][i]!='S')
            {
                if(s[j][i]!='p'){
                count++;
                s[j][i]='p';
                }
            }
            else
            {
                count=0;
                 for(int k=0; k<j; k++)
                {
                    s[k][i]='.';
                }
                break;
            }

            //cout<<count<<endl;

        }
        sum+=count;
    }
    cout<<sum<<endl;
}

#include <iostream>
#include <algorithm>

using namespace std;

char m[20][20];
int h[20][20]={0};
int r,c;
int ans=0;

int main()
{
    ios::sync_with_stdio(false);
    cin>>r>>c;
    for(int i=1;i<=r;i++)
        for(int j=1;j<=c;j++)
            cin>>m[i][j];
    for(int i=1;i<=r;i++)
        for(int j=1;j<=c;j++)
        {
            int tmp=0;
            if(m[i][j]=='S')continue;
            for(int k=1;k<=c;k++)
            {
                if(m[i][k]=='S'){tmp++;break;}
            }
            for(int k=1;k<=r;k++)
            {
                if(m[k][j]=='S'){tmp++;break;}
            }
            if(tmp<2)ans++;
        }
    cout<<ans<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int arrsum(int arr[] , int n)
{
    int xsum=0;
    for(int i=0 ; i<n ; i++){
        xsum+=arr[i];
    }
    return xsum ;
}

int main()
{
    int r , c ;  cin>>r>>c;
    char grid[r][c] ; int row[r] , columne[c];
    for(int i=0 ; i<r ; i++)
            row[i]=1 ;
    for(int j=0 ; j<c ; j++)
         columne[j]=1;
    bool test=true;
    for(int i=0 ; i<r ; i++){
        for(int j=0 ; j<c ; j++){
            cin>>grid[i][j];
    if(grid[i][j]=='S'){ test=false; row[i]=0 ;  columne[j]=0; }
        }
    }
    /*for(int i=0 ; i<r ; i++)
        cout<<row[i]<<' ' ;
    cout<<endl;
    for(int j=0 ; j<c ; j++)
        cout<< columne[j]<<' ';*/
    int rw=arrsum(row,r) , col=arrsum(columne,c);
    //cout<<rw<<' '<<col<<endl;
    int cmax=max(rw,col) , cmin=min(rw,col) , rr=rw*c , cc=col*r ;
    //cout<<rr<<' '<<cc;
    if(cmax>0 && cmin==0){ cout<<rr+cc; }
    else if(cmax==cmin && test==true){ cout<<rw*col; }
    //else if(cmax==cmin && test==false){ cout<<rr+cc-(cmax*cmin); }
    else{ cout<<rr+cc-(cmax*cmin); }

    return 0;
}

#include <iostream>
#include <vector>

using namespace std;

int main(){
	int r,c,mn=0,bb=0,okr,okc;
	cin >> r >> c;
	char tmp;
	int arr[r+5][c+5];
	int sr[15]={0};
	int sc[15]={0};
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			cin >> tmp;
			if(tmp=='S'){
				sr[i]=1;
				sc[j]=1;
				arr[i][j]=1;
				bb++;
			}else{
				arr[i][j]=0;
			}

		}
	}

	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			if(arr[i][j]!=1&&sc[j]==1&&sr[i]==1) mn++;

		}
	}

	//cout << arr[2][3] << endl;
	//cout << bb << endl;
	//cout << mn << endl;
	cout << r*c-bb-mn << endl;
	return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int r,c,cc=0,sum=0,row=0,colum=0; cin>>r>>c;
    char arr[r][c];
    int checkr[10]={0};
    int checkc[10]={0};
    for (int i=0;i<r;i++) {
        for (int j=0;j<c;j++) {
            cin>>arr[i][j];
        if (arr[i][j]=='S') {checkr[i]=1; checkc[j]=1;}
        }
    }
    for (int i=0;i<r;i++) {
        if (checkr[i]==0) {row+=c; cc++;}
        }
    for (int j=0;j<c;j++) {
        if (checkc[j]==0) {colum+=(r-cc);}
        }
    cout<<row+colum<<endl;
    return 0;
}

#include<iostream>
#include<string>
using namespace std;
int main()
{
    int a, b, x=0, t;
    string s[10];
    cin>>a>>b;
    for (int i=0; i<a; i++)
    cin>>s[i];
    for (int i=0; i<a; i++)
    {
        t=0;
        for (int j=0; j<b; j++)
        {
            if (s[i][j]=='.')
            t=1;
            else
            {
                t=0;
                break;
            }
        }
        if (t==1)
        x+=b;

    }
    int y=x;
    for (int i=0; i<b; i++)
    {
        t=0;
        for (int j=0; j<a; j++)
        {
            if (s[j][i]=='.')
            t=1;
            else
            {
                t=0;
                break;
            }
        }
        if (t==1)
        if (x!=0)
        x=x+(a-(y/b));
        else
        x+=a;
        //cout<<x;
    }
    cout<<x<<endl;
    //system ("pause");
    return 0;
}

#include <iostream>
#include <ctype.h>
#include <string.h>

using namespace std;

int main(){

	int r,c,evil=0,cleanRows,cleanColumns;

	cin >> r >> c;

	char cake[r][c];

	cleanRows = r;
	cleanColumns = c;

	for(int i=0;i<r;i++){
		for(int z=0;z<c;z++){
			cin >> cake[i][z];
		}
	}

	for(int i=0;i<r;i++){
		for(int z=0;z<c;z++){
			if(cake[i][z] == 'S'){
				cleanRows--;
				break;
			}
		}
	}
	for(int i=0;i<c;i++){
		for(int z=0;z<r;z++){
			if(cake[z][i] == 'S'){
				cleanColumns--;
				break;
			}
		}
	}
/*
	if(cleanColumns < 0){ cleanColumns = 0; }
	if(cleanRows < 0) { cleanRows = 0; }

	if(cleanRows == r && cleanColumns == c){
		cout << r*c;
	}else if(cleanRows == 0 || cleanColumns == 0){
		cout << (cleanRows * c) + (cleanColumns * r);
	}else if(cleanColumns > cleanRows){
		cout << (cleanRows * c) + (cleanColumns * r) - cleanColumns;
	}else if(cleanColumns < cleanRows){
		cout << (cleanRows * c) + (cleanColumns * r) - cleanRows;
	}else if(cleanColumns == cleanRows){
		cout << (cleanRows * c) + (cleanColumns * r) - cleanRows*cleanColumns;
	}
*/
	int evr = r-cleanRows;
	int evc = c-cleanColumns;
	cout << (r*c)-(evr*evc);
	cout <<"\n";
}

#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;

int main ()
{int n,m,counter=0,r=0,s=0,w=0;;
char arr [10][10];
    cin>>n>>m;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin>>arr[i][j];

        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if(arr[i][j]=='.')
            ++counter;
            else break;

        }
        if(counter==m)
        {

            ++w;
            r+=m;
            counter=0;
        }
        else counter=0;

    }

    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if(arr[j][i]=='.')
            ++counter;
            else break;
        }
        if(counter==n)
        {

            ++s;
            r+=n;
            counter=0;
        }
        else counter=0;

    }

    cout<<r-(w*s)<<endl;

return 0;
}

#include <bits/stdc++.h>
#include <iostream>

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

using namespace std;

int main() {

    int n,m;
    cin >> n >> m;
    int cnt = 0;
    bool row[100] = {false},column[100] = {false};
    char c[n+1][m+1];

    for(int i = 0; i<n; i++){
        for(int j = 0; j<m; j++){
            cin >> c[i][j];
            if(c[i][j] == 'S'){
                row[i] = true;
                column[j] = true;
            }
        }
    }

    for(int i = 0; i<n; i++){
        for(int j = 0; j<m; j++){
            if(!row[i] || !column[j])cnt++;
        }
    }

        cout << cnt;
}

// mainproj.cpp: определяет точку входа для консольного приложения.
//
#include <iostream>
#include <algorithm>
#include <string.h>
#include <conio.h>
#include <stdio.h>
#include <string>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <queue>
#include <map>
#include <numeric>
#include <iostream>
#include <sstream>
#include <fstream>
#include <cstring>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <list>
#include <cassert>
#include <ctime>
#include <climits>
#include <functional>
#include <set>
#include <sstream>
#include <clocale>
#include <stack>
#include <utility>
#include <vector>
#include <stdio.h>
#include <ctype.h>
#include <Windows.h>

#define forp(i,a,b)	for(int i=a ; i<b ; i++)
#define form(i,a,b)	for(int i=a ; i>b ; i--)
#define MAX 5000000
#define fout cout
#define fin cin

typedef long long int ll;

ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a%b);
}
bool funct_sort_down(int a, int b)
{
	return a > b;
}

using namespace std;

ll mas[MAX], number, ans, x, y, sh;
string str, fake, real;
char field[15][15];
int main()
{
	cin >> x >> y;
	forp(i, 0, x)
	{
		forp(a, 0, y)
			cin >> field[i][a];
	}
	forp(i, 0, x)
	{
		forp(a, 0, y)
		{
			if (field[i][a] == '.')
				sh++;
			else if (field[i][a] == '0')
				continue;
			else
			{
				sh = 0;
				break;
			}
		}
		if (sh != 0)
		{
			ans += sh;
			forp(a, 0, y)
				field[i][a] = '0';
		}
		sh = 0;
	}

	forp(a, 0, y)
	{
		forp(i, 0, x)
		{
			if (field[i][a] == '.')
				sh++;
			else if (field[i][a] == '0')
				continue;
			else
			{
				sh = 0;
				break;
			}
		}
		if (sh != 0)
		{
			ans += sh;
			forp(i, 0, x)
				field[i][a] = '0';
		}
		sh = 0;
	}
	cout << ans;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main(){
    int r, c;
    char str[15][15];
    scanf("%d %d", &r, &c);

    for(int i=0; i<r; i++){
        scanf("%s", str[i]);
    }

    int cnt=0, total=0;
    for(int i=0; i<r; i++){
        for(int j=0; j<c; j++){
            if(str[i][j]=='S'){
                cnt=0;
                break;
            }
            else cnt=1;
        }
        if(cnt!=0){
            total=total+c;
            for(int j=0; j<c; j++){
                str[i][j]='#';
            }
        }
    }

    for(int i=0; i<c; i++){
        cnt=0;
        for(int j=0; j<r; j++){
            if(str[j][i]=='.') cnt++;
            else if(str[j][i]=='S'){
                cnt=0;
                break;
            }
        }
        total=total+cnt;
    }

    cout<<total;

return 0;
}

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define TC int t; cin>>t; while(t--)
#define LL long long

bool vis[10][10];

int main()
{
	//TC
	{
		int r, c; cin>>r>>c;
		vector<string>cake(r);
		for(string &s:cake) cin>>s;

		int cnt=0;
		for(int i=0; i<r; i++)
		{
			bool f=true;
			for(int j=0; j<c; j++)
			{
				if(cake[i][j]=='S') { f=false; break; }
			}
			if(f)
			{
				for(int j=0; j<c; j++)
				{
					if(!vis[i][j]) vis[i][j]=true, cnt++;
				}
			}
		}

		for(int i=0; i<c; i++)
		{
			bool f=true;
			for(int j=0; j<r; j++)
			{
				if(cake[j][i]=='S') { f=false; break; }
			}
			if(f)
			{
				for(int j=0; j<r; j++)
				{
					if(!vis[j][i]) vis[j][i]=true, cnt++;
				}
			}
		}

		cout<<cnt<<endl;
	}
}

#include <iostream>
using namespace std;
char a[12][12];
int n,m;
bool notS1(int i)
{
	int x=0;
		for(int j=0;j<m;j++)
			if(a[i][j]=='S')
		x++;
		if(x==0)
			return true;
		else
			return false;
}

bool notS2(int j)
{
	int y=0;
		for(int i=0;i<n;i++)
			if(a[i][j]=='S')
			y++;
			if(y==0)
				return true;
			else
				return false;
}

int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
		if(notS1(i))
			for(int j=0;j<m;j++)
				a[i][j]='*';
	for(int j=0;j<m;j++)
		if(notS2(j))
			for(int i=0;i<n;i++)
				a[i][j]='*';
	int k=0;
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			if(a[i][j]=='*')
				k++;
	cout<<k<<endl;
	return 0;
}

#include <iostream>
using namespace std;

int main() {

	char a[10][10];
	int r ,c ;

	cin>>r>>c;
	int r2=0 ,c2=0;
	for(int i=0 ;i<r ;i++){
		for(int j=0 ;j<c ;j++){
			cin>>a[i][j];

		}

	}
	bool f=0;
	for(int i=0 ;i<r ;i++){
		f=0;
		for(int j=0 ;j<c ;j++){
			if(a[i][j]=='S')
			f=1;
		}
		if(f){
		r2++;
		}
	}

	for(int i=0 ;i<c ;i++){
		f=0;
		for(int j=0 ;j<r ;j++){
			if(a[j][i]=='S')
			f=1;
		}
		if(f){
		c2++;
		}
	}

	cout<<r*c - r2*c2;

	return 0;
}

#include <iostream>
#include <vector>
using namespace std;
int main ()
{
    int m,n, temp1 = 0, temp2 = 0;
    char c;
    cin  >> m >>n;
    vector < vector <char> > x (m, vector <char> (n));

    for (int i= 0; i< m; i++)
    {
        for (int j = 0; j <n; j++)
        {
            cin >> c;
            x[i][j]= c;
        }
    }
    for ( int i =0; i <m; i++)
    {
        for (int j=0; j <n; j++)
        {
            if (x[i][j] == 'S')
            {
                temp1 = 1;
            }
            if  (x[i][j] == '.')
            {
                temp2 = 1;
            }
        }
        if ( !temp1 && temp2)
        {
            for (int j =0; j<n; j++)
            {
                x[i][j] = ' ';
            }
        }
        temp1 = 0;
        temp2 = 0;
    }
    temp1 = 0, temp2 = 0;
    for ( int j =0; j <n; j++)
    {
        for (int i=0; i <m; i++)
        {
            if (x[i][j] == 'S')
            {
                temp1 = 1;
            }
            if  (x[i][j] == '.')
            {
                temp2 = 1;
            }
        }
        if ( !temp1 && temp2)
        {
            for (int i =0; i<m; i++)
            {
                x[i][j] = ' ';
            }
        }
        temp1 = 0;
        temp2 = 0;
    }
    int count = 0;
    for (int i= 0; i< m; i++)
    {
        for (int j = 0; j <n; j++)
        {
            if ( x[i][j] == ' ')
            {
                count ++;
            }
        }
    }
        cout << count;
        return 0;
}

#include <iostream>
#include<bits/stdc++.h>
using namespace std;
char arr[1000][20000];
int main()

{
    int row=0;int colum=0;
    int sum=0,coun=0;

int n,m;
cin>>n;
cin>>m;
for(int i=0;i<n;i++)
{
    for(int j=0;j<m;j++)
        cin>>arr[i][j];

}

for(int i=0;i<n;i++)
{
    for(int j=0;j<m;j++)
    {

        if(arr[i][j]=='S')
    {
        row++;
    }
        if(row>=2)
            row=1;
            //sum=sum+row;
    }

sum=sum+row;
row=0;
}
for(int j=0;j<m;j++)
{
    for(int i=0;i<n;i++)
{

        if(arr[i][j]=='S')
        {
           colum++;
        }
          if(colum>=2)
           colum=1;
}

   coun=coun+colum;
   colum=0;
}
/*cout<<"\n the sum is   "<<sum;
cout<<"\n the coun is  "<<coun;
cout<<"\n";*/
sum=n-sum;
int x=sum*m;

 coun =m-coun;
int w=coun*n;

 int max1=x+(w-coun*sum);
//cout<<"\n";
cout<<max1;

    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <cstring>

#define VI vector <int>
#define VS vector <string>
using namespace std;

int main() {
    int r, c;
    scanf("%d %d\n",&r,&c);
    bool rr[11], cc[11];
    for(int i = 0; i < 11; i++) {rr[i] = cc[i] = true;}
    for(int i = 0; i < r; i ++){
        char t[11]; scanf("%s",t);
        for(int j = 0; j < strlen(t); j++)
        if(t[j] == 'S') {rr[i] = false; cc[j] = false;}
    }
    int x = 0, y = 0;
    for(int i = 0; i < r; i++) if(rr[i]) x++;
    for(int i = 0; i < c; i++) if(cc[i]) y++;
    printf("%d\n",x * c + y * r - x * y);
return 0;
}

/*
Problem from CodeForces!

#330A Cakeminator

Tags: ["Brute Force" : "Implementation" : "900"]

Link: https://codeforces.com/problemset/problem/330/A
*/

/*
	Written by: Aryan V S
	Date: Friday 2020-02-16
*/

#include <bits/stdc++.h>

#if 0
	#include "z_debug.h"
#else
	#define dchar   char
	#define int32   int
	#define uint32  unsigned int
	#define int64   long long
	#define uint64  unsigned long long
	#define dsize_t size_t
	#define dfloat  float
	#define ddouble double
	#define Debug(...)
#endif

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define mod     1000000007
#define eps     1e-9
#define elif    else if
#define eb      emplace_back
#define pf      push_front
#define pb      push_back
#define ppf     pop_front
#define ppb     pop_back
#define mp      make_pair
#define nl      '\n'
#define all(x)  x.begin () , x.end ()
#define rall(x) x.rbegin () , x.rend ()

int main ()
{
	ios::sync_with_stdio (false);
	cin.tie (nullptr); cout.tie (nullptr);
	cout.precision (10);
	cout << fixed << boolalpha;

	int Row, Col, Eatable = 0;
	string Cake_Row;
	cin >> Row >> Col;
	vector <vector <int>> Cake (Row, vector <int> (Col, 0));

	for (int i = 0; i < Row; i++)
	{
		cin >> Cake_Row;
		for (int j = 0; j < Col; j++)
			if (Cake_Row [j] == 'S')
				Cake [i][j] = -1;
	}

	for (int i = 0; i < Row; i++) {
		bool Okay = true;
		for (int j = 0; j < Col; j++) {
			if (Cake [i][j] == -1)
			{ Okay = false; break; }
		}
		if (Okay) {
			Eatable += count (all (Cake [i]), 0);
            for (int& j : Cake [i]) j = 1;
		}
	}

	for (int i = 0; i < Col; i++) {
		bool Okay = true;
		for (int j = 0; j < Row; j++) {
			if (Cake [j][i] == -1)
			{ Okay = false; break; }
		}
		if (Okay) {
			for (int j = 0; j < Row; j++)
				if (Cake [j][i] == 0)
				{ Eatable++; Cake [j][i] = 1; }
		}
	}

	cout << Eatable;

	return 0;
}

#include<iostream>
#include<string>
using namespace std;
int main (){

  int Data1 , Data2, Attack=0;
  char Search[11][11];
  cin >> Data1 >> Data2;
  for(int i=0 ; i<Data1 ; i++)
    for(int i2=0 ;i2<Data2 ; i2++)
       cin >> Search[i][i2];
  for(int i=0 ; i<Data1 ; i++)
  {
    bool Go_ahead1=true;
    for(int i2=0; i2<Data2 ; i2++)
      if(Search[i][i2]=='S')Go_ahead1=false;
    if(Go_ahead1)
    {
      Attack+=Data2;
      for(int i2=0 ;i2<Data2 ; i2++)
        Search[i][i2]='X';

    }
  }
  for(int i=0 ; i<Data2 ; i++)
  {
    bool Go_ahead2=true;
    int Attack2=0;
    for(int i2=0 ; i2<Data1 ; i2++)
    {
      if(Search[i2][i]=='S')Go_ahead2=false;
      else if(Search[i2][i]=='.'){Attack2++;}
    }
    if(Go_ahead2)Attack+=Attack2;
  }
  cout << Attack;
  return 0;
}

#include <iostream>
#include <string>

using namespace std;

void main()
{
	int r, c, ans = 0;
	cin>>r>>c;
	string *s1 = new string [ r ];
	string *s2 = new string [ c ];
	int *size1 = new int [ r ];
	for( int i = 0; i < r; ++i )
		size1[ i ] = 0;
	int *size2 = new int [ c ];
	for( int i = 0; i < c; ++i )
		size2[ i ] = 0;
	for( int i = 0; i < r; ++i )
	{
		for( int j = 0; j < c; ++j )
		{
			char q;
			cin>>q;
			s1[ i ] += q;
			s2[ j ] += q;
		}
		size1[ i ] += s1[ i ].size();
		if( s1[ i ].find( 'S' ) == s1[ i ].npos && s1[ i ].find( 's' ) == s1[ i ].npos )
		{
			ans += size1[ i ];
			for( int j = 0; j < c; ++j )
				size2[ j ] -= 1;
		}
	}
	for( int i = 0; i < c; ++i )
	{
		size2[ i ] += s2[ i ].size();
		if( s2[ i ].find( 'S' ) == s2[ i ].npos && s2[ i ].find( 's' ) == s2[ i ].npos )
			ans += size2[ i ];
	}
	cout<<ans<<endl;
}

#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define FOR(I,A,B)	for(int I = (A); I < (B); ++I)
#define REP(I,N)	FOR(I,0,N)
#define vi vector<int>
#define vmat vector < vi >

using namespace std;

int seeRows(vmat &mat){
    int p = 0;
    REP(i, mat.size()){
        int count = 0;
        REP(j, mat[i].size()){
            if(mat[i][j] != -1){
                count += mat[i][j];
            } else {
                count = 0;
                break;
            }
        }
        if(count > 0){
            REP(j, mat[i].size()){
                mat[i][j] = 0;
            }
        }
        p += count;
    }
    return p;
}

int main()
{
    int R, C;
    cin >> R >> C;
    vmat mat(R,vi(C));
    REP(i,R){
        string s;
        cin >> s;
        REP(j, C){
            if(s[j] == 'S') mat[i][j] = -1;
            if(s[j] == '.') mat[i][j] = 1;
        }
    }

    int p = seeRows(mat);
    vmat trans(C, vi(R));
    REP(i, trans.size()){
        REP(j, trans[i].size()){
            trans[i][j] = mat[j][i];
        }
    }
    p += seeRows(trans);
    cout << p << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main(){
	int N,M,x,a=0,b=0,c=0,d=0;
	cin>>N>>M;
	x=N*M;
	string S[N];
	for(int k=0;k<N;k++)
		cin>>S[k];
	for(int i=0;i<N;i++){
		a=0;
		for(int j=0;j<M;j++)
			if(S[i][j]=='S')
			a++;
			if(a>0)
			c++;

}
	for(int j=0;j<M;j++){
		b=0;
		for(int i=0;i<N;i++)
			if(S[i][j]=='S')
			b++;
			if(b>0)
			d++;
	}

	cout<<x-(c*d);
	return 0;
}

#include<iostream>
#include<set>

int main()
{
	std::set<int> row_count;
	std::set<int> col_count;
	std::string s;
	int n,m;
	std::cin>>n>>m;
	int count=0;
	for(int i = 0;i < n;i++)
	{
		std::cin>>s;
		for(int j = 0;j < m; j++)
		{

			if (s[j] =='S')
			{
				row_count.insert(i);
				col_count.insert(j);
				count+=1;
			}
		}
	}
	//std::cout<<(m*n) - row_count.size()*col_count.size();
	int remaining_row = n-row_count.size();
	int remaining_col = m-col_count.size();
	int ans = (remaining_row*m) + (remaining_col*n) - (remaining_row*remaining_col);
	std::cout<<ans<<"\n";

}

#include <bits/stdc++.h>
using namespace std;

int r, c, res;
string s[10];
bool filas[11], columnas[11];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	cin >> r >> c;
	for (int i = 0; i < r; i++)
		cin >> s[i];
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			if (s[i][j] == 'S') {
				filas[i] = columnas[j] = 1;
            }
        }
	}
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			if (!filas[i] || !columnas[j]) {
				res++;
            }
        }
    }
	cout << res << "\n";
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(), v.end()
#define endl "\n"
#define LCM(m,n) m*(n/__gcd(m,n))
#define foor(i,n) for(ll i=0;i<n;i++)
#define foor1(i,n) for(ll i=1;i<n;i++)
#define foora(i,a,n) for(ll i=a;i<n;i++)
#define hell 1000000007
#define sz(x) (ll)x.size()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define LCM(m,n) m*(n/__gcd(m,n))
#define N1 1000000
#define N2 1000000000

int main()
{
 FAST
//code begins from here//
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
ll r,c;
cin>>r>>c;
char cake[r][c];
foor(i,r)
{
  foor(j,c)   cin>>cake[i][j];
}
int count[r][c] = {{0,0,0,0}};
int ans = 0;
// Row Wise
int row = 0, col = 0;
foor(i,r)
{
  ll cnt = 0;
  foor(j,c)
  {
    if(cake[i][j] == '.')  cnt++;
  }
  // cout<<i<<" "<<cnt<<endl;
  if(cnt == c)
  {
    ans += cnt;
    row++;
   //cout<<i<<" "<<cnt<<endl;
   /*
   foor(j,c)
   {
     if(count[i][j] == 0 )  count[i][j]++;
   }
   */
  }
}

// Column Wise

foor(j,c)
{
  ll cnt = 0;
  foor(i,r)
  {
    if(cake[i][j] == '.')  cnt++;
  }
  if(cnt == r)
  {
    ans += cnt;
    col++;
    /*
   foor(i,r)
   {
    if(count[i][j] == 0 )  {  count[i][j]++;   }
   }
   */
  }
}

foor(i,r)
{
  foor(j,c)   if(count[i][j] == 1)  ans++;
}
cout<<ans - (row*col)<<endl;
/*
foor(i,r)
{
  foor(j,c)   cout<<count[i][j]<<" ";
  cout<<endl;
}
*/
return 0;
}

#include <algorithm>
#include <iostream>
#include <iterator>
#include <string>
#include <vector>

void answer(size_t v)
{
    std::cout << v << '\n';
}

void solve(const std::vector<std::string>& p, size_t c)
{
    const size_t r = p.size();

    size_t rc = 0;
    for (size_t i = 0; i < r; ++i) {
        for (size_t j = 0; j < c; ++j) {
            if (p[i][j] == 'S') {
                ++rc;
                break;
            }
        }
    }

    size_t cc = 0;
    for (size_t j = 0; j < c; ++j) {
        for (size_t i = 0; i < r; ++i) {
            if (p[i][j] == 'S') {
                ++cc;
                break;
            }
        }
    }

    answer(r * c - rc * cc);
}

int main()
{
    size_t r, c;
    std::cin >> r >> c;

    std::vector<std::string> p(r);
    std::copy_n(std::istream_iterator<std::string>(std::cin), std::size(p), std::begin(p));

    solve(p, c);

    return 0;
}

#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstdio>
#include <math.h>
#include <vector>
#include <list>
#include <map>
#include <set>
using namespace std;

int main()
{
    int r, c, t=0, p=0, m;
    cin>>r>>c;
    char a[r][c];
    for (int i=0; i<r; i++)
    {
        for (int j=0; j<c; j++)
        {
            cin>>a[i][j];
        }
    }
    for (int i=0; i<r; i++)
    {
        m=1;
        for (int j=0; j<c; j++)
        {
            if (a[i][j]=='S') m=0;
        }
        if (m==1) {t+=c; p++;}
    }
    for (int i=0; i<c; i++)
    {
        m=1;
        for (int j=0; j<r; j++)
        {
            if (a[j][i]=='S') m=0;
        }
        if (m==1) {t+=r-p;}
    }
    cout<<t<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int r,c;
    cin>>r>>c;
    int count=0;
    string arr[r];
    for(int i=0;i<r;i++)
    {

            cin>>arr[i];

    }
    int cl[r][c],fl;

    for(int i=0;i<r;i++)
    {
        for(int j=0;j<c;j++)
        {
            if(arr[i][j]=='S')
            {
                cl[i][j]=-1;
            for(int k=i;k<r;k++)
            {
                if(k==i)
                fl=j+1;
                else
                fl=0;

                for(int p=fl;p<c;p++)
                {
                    if(arr[k][p]=='S')
                    {

                        cl[k][p]=-1;
                        cl[i][p]=-1;
                        cl[k][j]=-1 ;

                    }
                }
            }
            }
        }

    }
    for(int i= 0;i< r; i++)
    {
        for(int j= 0;j<c;j++)
        {
            if(cl[i][j]==-1)
            count++;
        }
    }

cout<<r*c-count;
}

#include<iostream>
#include<string>
using namespace std;

    bool r[11];
    bool c[11];

int main() {
    int rows;
    int columns;
    cin >> rows >> columns;
    string str;
    for(int i = 1; i <= rows; i++) {
        cin >> str;
        for(int j = 1; j <= columns; j++) {
            if(str[j-1]!='.') {
                r[i] = true;
                c[j] = true;
            }
        }
    }
    int sum = 0;
    int nre = 0;
    for(int i = 1; i <= rows; i++) {
        if(!r[i]) {
            sum += columns;
            //cout << "sum " << sum << endl;
            nre++;
        }
    }
    int temp;
    if(rows > nre) {
        temp = rows - nre;
        for(int i = 1; i <= columns; i++) {
            if(!c[i]) {
                sum += temp;
                //cout << "sum " << sum << endl;
            }
        }
    }
    cout << sum;
    return 0;
}

#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include <functional>
#include <sstream>
#include<stack>
#include<queue>
using namespace std;
int main()
{
    int r, c;
    cin >> r >> c;
    char**a = new char*[r];
    for (int i = 0; i < r; i++)
    {
        a[i] = new char[c];
    }
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            cin >> a[i][j];
        }
    }
    int sum = 0;
    int sum1 = 0;
    int sum2 = 0;
    bool test = true;
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            if (a[i][j] == 'S')test = false;
        }
        if (test)
        {
            for (int j = 0; j < c; j++)
            {
                if (a[i][j] == '.')
                {
                    sum1++;
                    a[i][j] = 'f';
                }
            }
            sum += sum1;
            sum1 = 0;
        }
        test = true;
    }
    test = true;
    for (int i = 0; i < c; i++)
    {
        for (int j = 0; j < r; j++)
        {
            if (a[j][i] == 'S')test = false;
        }
        if (test)
        {
            for (int j = 0; j < r; j++)
            {
                if (a[j][i] == '.')
                {
                    sum2++;
                    a[j][i] = 'f';
                }
            }
            sum += sum2;
            sum2 = 0;
        }
        test = true;
    }
    cout << sum;
}

#include <iostream>
using namespace std;
int n, m, arr[11][11], ind, ans;
char c;
int main() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> c;
            if (c == 'S') {
                arr[i][j] = 1;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        ind = 0;
        for (int j = 0; j < m; j++) {
            if (arr[i][j] == 1) {
                ind = 1;
                break;
            }
        }
        if (ind == 0) {
            for (int j = 0; j < m; j++) {
                arr[i][j] = 2;
            }
        }
    }
    for (int i = 0; i < m; i++) {
        ind = 0;
        for (int j = 0; j < n; j++) {
            if (arr[j][i] == 1) {
                ind = 1;
                break;
            }
        }
        if (ind == 0) {
            for (int j = 0; j < n; j++) {
                arr[j][i] = 2;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (arr[i][j] == 2) {
                ans++;
            }
        }
    }
    cout << ans;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
  int i,j,r,c,c1=0,c2=0;
	cin>>r>>c;
	string s[10];
	for(i=0;i<r;i++)
    cin>>s[i];
	for(i=0;i<r;i++){
    for(j=0;j<c;j++){
    if(s[i][j]=='S'){
    c1++;break;
    }
    }
	}
	for(i=0;i<c;i++ ){
    for(j=0;j<r;j++){
    if(s[j][i]=='S'){
    c2++;break;
    }
    }
	}
	cout<<(c*r)-(c1*c2)<<endl;
    return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
int r,c,tg=0;
int main()
{
	cin>>r>>c;
	char a[r][c];
	memset(a,'.',sizeof(a));
	getchar();
	for(int i=0;i<r;i++)
	{
		int dem=0;
		char b;
		for (int j=0;j<c;j++)
		{
			scanf("%c",&b);
			if(b=='.')
				dem++;
			if(b!='.')
				a[i][j]='S';
		}
		getchar();
		if (dem==c)
		{
			for (int j=0;j<c;j++) a[i][j]='1';
			tg+=dem;
		}
	}
	for(int i=0;i<c;i++)
	{
		int	dem=0;
		for (int j=0;j<r;j++)
		{
			if(a[j][i]=='.' || a[j][i]=='1')
				dem++;
			else
				break;
		}
		if(dem==r)
		{
			tg+=dem;
			for(int k=0;k<r;k++)
			{
				if (a[k][i]=='1') tg-=1;
			}
		}
	}
	cout<<tg;
	return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int a,b;
    string aux;
    char ar[100][100];
    while(cin>>a>>b)
    {
        for(int i=0; i<a; i++)
        {
            cin>>aux;
            for(int j=0; j<b; j++)
            {
                ar[i][j]=aux.at(j);
            }
        }
        int aux=0,resu=0;
        for(int i=0; i<a; i++)
        {
            aux=0;
            for(int j=0; j<b; j++)
            {
                if(ar[i][j]=='S')
                {
                    aux=0;
                    break;
                }
                if(ar[i][j]!='x')
                    aux++;
                ar[i][j]='x';
            }
            if(aux==0)
                for(int j=0; j<b; j++)
                {
                    if(ar[i][j]!='S')
                    {
                        ar[i][j]=',';
                    }
                }
            resu+=aux;
        }
        //cout<<resu<<endl;
        for(int i=0; i<a; i++)
        {

            for(int j=0; j<b; j++)
            {
               // cout<<ar[i][j];
            }
           // cout<<endl;
        }
        for(int i=0; i<b; i++)
        {
            aux=0;
            for(int j=0; j<a; j++)
            {
                if(ar[j][i]=='S')
                {
                    aux=0;
                    break;
                }
                if(ar[j][i]!='x')
                    aux++;
                ar[j][i]='x';
            }
            if(aux==0)
                for(int j=0; j<a; j++)
                {
                    if(ar[j][i]!='S')
                    {
                        ar[j][i]=',';
                    }
                }
            //cout<<aux<<endl;
            resu+=aux;
        }
        for(int i=0; i<a; i++)
        {

            for(int j=0; j<b; j++)
            {
              //  cout<<ar[i][j];
            }
            //cout<<endl;
        }
        cout<<resu<<endl;
    }
    //cout << "Hello world!" << endl;
    return 0;
}

#include <iostream>
using namespace std;

int c[10],r[10];

int main()
{
	int n,m;
	cin >> n >> m;
	char a[n][m];
	for (int i = 0; i < n; ++i)
		for (int k = 0; k < m; ++k)
		{
			cin >> a[i][k];
			if (a[i][k] == 'S')
			{
				c[k] = 1;
				r[i] = 1;
			}
		}
	int num = 0;
	for (int i = 0; i < n; ++i)
	{
		if (r[i] == 1) continue;
		for (int k = 0; k < m; ++k) a[i][k] = 'q';
	}
	for (int k = 0; k < m; ++k)
	{
		if (c[k] == 1) continue;
		for (int i = 0; i < n; ++i) a[i][k] = 'q';
	}
	for (int i = 0; i < n; ++i)
		for (int k = 0; k < m; ++k)
			if (a[i][k] == 'q') ++num;
	cout << num;
//	system("pause");
}

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
using namespace std;

int map[20][20];

int main(){
	int x,y;
	while(scanf("%d%d",&x,&y)!=EOF){
		memset(map,0,sizeof(map));
		int i,j,r=0,c=0;
		for(i=0;i<x;i++){
			getchar();
			for(j=0;j<y;j++){
				scanf("%c",&map[i][j]);
			}
		}
		int flag=0;
		for(i=0;i<x;i++){
			for(j=0;j<y;j++){
				if(map[i][j]=='.'){
					flag=0;
				}
				else{
					flag=1;
					break;
				}
			}
			if(flag==0){
				r++;
			}
			else{
				flag=0;
			}
		}
		for(i=0;i<y;i++){
			for(j=0;j<x;j++){
				if(map[j][i]=='.'){
					flag=0;
				}
				else{
					flag=1;
					break;
				}
			}
			if(flag==0){
				c++;
			}
			else{
				flag=0;
			}
		}
		printf("%d\n",c*x+y*r-c*r);
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
set<int>a,b;
int main()

{
int r,c,i,j;

char ch;
cin>>r>>c;
for(i=0;i<r;i++){
for(j=0;j<c;j++){
    cin>>ch;
    if(ch=='S'){a.insert(i);b.insert(j);}
}
}
cout<<r*c-a.size() * b.size();

    return 0;

}

///....................SUBRATO MOLLICK....................///
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///........................BETCH-10.......................///
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,n) for(__typeof(n) i=0; i<(n); i++)
#define REP2(i,n) for(__typeof(n) i=1; i<=(n); i++)
#define FOR(i,a,b) for(__typeof(b) i=(a); i<=(b); i++)
#define INF (1<<30)
#define PI 3.14159265358979323846264338327950
#define PB(x) push_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ size()
#define eps 1e-9
#define VI vector<int>
#define VS vector<string>
#define LL long long
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define CLEAR(x) memset(x,0,sizeof(x));
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)
#define all(x) x.begin(),x.end()

using namespace std;

/*long long c[201]={0};
bool p[205]={0};
void sieve()
{
   long long i,j;
    j=4;
     while(j<=201)
     {
         p[j]=1;
         j+=2;
     }
     long k=1;
     for(i=3;i<=(201);i+=2)
     {
        if(p[i]==0)
        {
            j=i;
            while(j+i<=201)
            {
                p[j+i]=1;j+=i;
            }
            if(p[i+2]==0)
            c[k++]=i;
        }
    }
}*/
/*long long npr(long n,long m)
{
   long long ret=1,i;
   for(i=1;i<=m;i++)
   ret*=(n-i+1);
   return ret;
}*/
/*long long ncr(long n,long m)
{
   long long ret=1,i;
   for(i=1;i<=m;i++)
   {
       ret*=(n-i+1);
       ret/=i;
   }
   return ret;
}*/
/*long long fact(long n)
{
    long long ret=1,i;
    for(i=1;i<=n;i++)
    ret*=i;
    return ret;
}*/
/*long long gcd(long n,long m)
{
  while(m>0)
  {
    n=n%m;
    n=n^m;
    m=m^n;
    n=n^m;
  }
  return n;
}*/
/*long long lcm(long n,long m)
{
    long long x=(n*m)/gcd(n,m);
    return x;
}*/
/*long is_prime(long n)
{
	long long ii;
	if(n == 1)
	return 0;
	if(n == 2)
	return 1;
	if(n%2 == 0)
	return 0;
	for(ii=3;ii*ii<=n;ii=ii+2)
        if(n%ii == 0)
        return 0;
        return 1;
}*/
/*double area_triangle(double x1,double y1,double x2,double y2,double x3,double y3)
{
    double a;
    a=x1*(y2-y3)+y1*(x3-x2)+((x2*y3)-(y2*x3))+eps;
    a=a/2+eps;
    return a;
}*/
/*double dist_2point(double x1,double y1,double x2,double y2)
{
    double d;
    d=sqrt(((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)));
    return d;
}*/
/*int binary_search(int a[],int n,int l,int u)
{
	int mid;
	if(l>u)
    return 0;
    mid=floor(l+u)/2;
    if(a[mid]==n)
    return mid;
    else if(a[mid]>n)
    binary_search(a,n,l,mid-1);
    else
    binary_search(a,n,mid+1,u);
}*/
/*bool is_palindrome(const string &s, int start, int end)
{
    int siz=end-start+1;
    if(siz%2==0)
    {
        int middle=start+siz/2;
        int i;
        for(i =0;middle-1-i>=0&&middle+i<=end&&s[middle-1-i]==s[middle+i];i++);
        if(middle-i-1<0||middle+i>end)
        return true;
    }
    else
    {
        int middle = start + siz/2;
        int i;
        for (i=1;middle-i>=0&&middle+i<=end&&s[middle-i]==s[middle+i];i++);
        if (middle-i<0||middle+i>end)
        return true;
    }
    return false;
}*/
int main()
{

    //freopen("Input.txt","r",stdin);
	//freopen("Output.txt","w",stdout);
	long row,col;
	while(cin>>row>>col)
	{
	    long i,j,k=0,t=0,p=0,b[100][20]={0};
	    string a[220];
	    REP(i,row)
	    {
            cin>>a[i];
	    }
	    REP(i,row)
	    {
	        REP(j,col)
	        {
	            if(a[i][j]=='.'||a[i][j]=='p')
	            k++;
	        }
	        if(k==col)
	        {
	            t++;
	            p=p+col;
	            REP(j,col)
	            a[i][j]='p';
	        }
	        k=0;
	    }
	    REP(i,col)
	    {
	        REP(j,row)
	        {
	            if(a[j][i]=='.'||a[j][i]=='p')
	            k++;
            }
	        if(k==row)
	        {
	            t++;//cout<<k<<endl;
	            //p=p+row;
	            REP(j,row)
	            if(a[j][i]=='.')
	            p++;
	        }
	        k=0;
	    }
	    //if(t==0)
	    //cout<<"0"<<endl;
	    //lse
	    cout<<p<<endl;
        }
return 0;
}

#include <iostream>
using namespace std;

int main() {

    int r, c;
    do cin >> r;
    while (r<2 || r>10);
    do cin >> c;
    while (c<2 || c>10);

    int eat=0, ccount=0, rcount=0;
    bool flag = true;

    char **p;
    p = new char* [r];
    for (int i=0; i<r; i++)
        p[i] = new char [c];

    for (int i=0; i<r; i++)
    {
        for(int j=0; j<c; j++)
            cin >> p[i][j];
    }

    for (int i=0; i<r; i++)
    {
        flag = true;
        for (int j=0; j<c && flag; j++)
        {
            if(p[i][j] == 'S')
                flag = false;
        }
        if (flag)
        {
            eat+=c;
            ccount++;
        }
    }

    for (int i=0; i<c; i++)
    {
        flag = true;
        for (int j=0; j<r && flag; j++)
        {
            if(p[j][i] == 'S')
                flag = false;
        }
        if (flag)
        {
            eat+=r;
            rcount++;
        }
    }

    eat = eat - (rcount*ccount);
    cout <<  eat;

    delete p;

    return 0;
}

#include <iostream>
using namespace std;
int n,m;
int r[11],c[11];
int ans;
int main()
{
    cin>>n>>m;
    for(int i=0;i<n;++i)
        for(int j=0;j<m;++j)
        {
            char ch;
            cin>>ch;
            if(ch=='S')
                r[i]=c[j]=1;
        }
    ans=n*m;
    for(int i=0;i<n;++i) for(int j=0;j<m;++j) if(r[i] && c[j]) ans--;
    cout<<ans<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int res=0;
int cnt=0;
int main()
{
	int a,b;
	cin>>a>>b;
	char x[1000][1000];
	for(int i=0;i<a;i++)
	{
		for(int j=0;j<b;j++)cin>>x[i][j];
	}
	for(int i=0;i<a;i++)
	{
		for(int j=0;j<b;j++)
		{
			if(x[i][j]=='S')
			break;
			if(j==b-1)
			res++;
		}
	}
	for(int i=0;i<b;i++)
	{
		for(int j=0;j<a;j++)
		{
			if(x[j][i]=='S')
			break;
			if(j==a-1)
			cnt++;
		}
	}
	cout<<res*b+cnt*a-res*cnt<<endl;
	return 0;
}

#include <bits/stdc++.h>
#define ioi exit(0);
#define ll long long
#define NMAX 1000000
#define nl endl
#define fi first
#define se second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define NFS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define clc clock() / (double)CLOCKS_PER_SEC

const int N = 1e5 + 1;
const ll inf = (ll)1e18 + 1;

using namespace std;

int n, m;
int q;
int w, e;
char s[100][100];
bool b[100][100];
int main(){
    NFS
	cin >> n >> m;
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < m; ++j){
			cin >> s[i][j];
		}
	}
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < m; ++j){
			if(s[i][j] != 'S') q++, w++;
		}
		if(w == m){
			for(int j = 0; j < m; ++j){
				b[i][j] = 1;
			}
		}
		else q -= w;
		w = 0;
	}
	for(int i = 0; i < m; ++i){
		for(int j = 0; j < n; ++j){
			if(s[j][i] != 'S') e++;
		}
		if(e == n){
			for(int j = 0; j < n; ++j){
				if(b[j][i] == 0) q++;
				b[j][i] = 1;
			}
		}
		e = 0;
	}
	cout << q, ioi
	ioi
}

#include <iostream>
#include <string>

using namespace std;

int main()
{
    int r, c, row[11] = {0}, col[11] ={0};
    string s;
    cin >> r >> c;
    for (int i = 0; i < r; ++i)
    {
        cin >> s;
        for (int j = 0; j < c; ++j)
        {
            if (s[j] == 'S')
            {
                row[i] = 1;
                col[j] = 1;
            }
        }
    }
    int cakes(0);
    for (int i = 0; i < r; ++i)
    {
        for (int j = 0; j < c; ++j)
        {
            if (row[i] == 0 || col[j] == 0)
            {
                cakes += 1;
            }
        }
    }
    cout << cakes << endl;
    return 0;
}

#include<iostream>
#include<vector>
using namespace std;
int a[10000],b[10000];
int main()
{
    long long int i,j,n,r,c,cnt=0;
    char ch;
    vector<vector<char> >v;
    vector<int>c1,r1;
    cin>>r>>c;
    for(i=0; i<r; i++)
    {
        vector<char>temp;
        for(j=0; j<c; j++)
        {
            cin>>ch;
            temp.push_back(ch);
            if(ch=='S')
            {
                a[i]=1;
                b[j]=1;
            }
        }
        v.push_back(temp);
    }
    for(i=0; i<r; i++)
    {
        for(j=0; j<c; j++)
        {
            if(a[i]==0)
            {
                cnt++;
                v[i][j]='p';
            }
        }
    }
   /* for(i=0;i<r;i++)
    {
        for(j=0;j<c;j++)
            cout<<v[i][j];
        cout<<endl;
    }*/
   // cout<<cnt<<endl;
    for(i=0; i<r; i++)
    {
        for(j=0; j<c; j++)
        {
            if(b[j]==0&&v[i][j]!='p')
                cnt++;
        }
    }
    v.clear();
    cout<<cnt<<endl;
    //main();
    return 0;
}

#include <iostream>
#include <string>
using namespace std;
bool NgR[10],NgC[10],pos[10][10];
int main(){
    int n,m,r=0;
    cin >> n >> m;
    char c[10][10];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> c[i][j];
            if(c[i][j]=='S'){
                NgR[i]=true;
                NgC[j]=true;
            }
        }
    }

    for(int i=0;i<m;i++){
        if(!NgC[i]){
            for(int j=0;j<n;j++){
                if(pos[j][i]==false){
                    r++;
                    pos[j][i]=true;
                }
            }
        }
    }

    for(int i=0;i<n;i++){
        if(!NgR[i]){
            for(int j=0;j<m;j++){
                if(pos[i][j]==false){
                    r++;
                    pos[i][j]=true;
                }
            }
        }
    }
    cout << r;
}

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#define int long long
using namespace std;

signed main(){
    int n, m; cin>>n>>m;
    vector<string>v;
    for(int i = 0; i<n; ++i){
        string a; cin>>a;
        v.push_back(a);
    }
    int counter = 0;

    for(int j = 0; j<m; ++j){
        if(v[0][j] == '.' ||v[0][j] == 'e'){
            int flag = 0;
            for(int k = 0; k<n; ++k){
                if(v[k][j] == 'S') flag = 1;
            }
            if(flag != 1){
                for(int k = 0; k<n; ++k){
                    v[k][j] = 'e';
                }
            }
        }
    }
    for(int i = 0; i<n; ++i){
        if(v[i][0] == '.' || v[i][0] == 'e'){
            int flag = 0;
            for(int k = 0; k<m; ++k){
                if(v[i][k] == 'S') flag = 1;
            }
            if(flag != 1){
                for(int k = 0; k<m; ++k){
                    v[i][k] = 'e';
                }
            }
        }
    }

    for(int i = 0; i<n; ++i){
        for(int j = 0; j<m; ++j){
            if(v[i][j] == 'e') counter += 1;
        }
    }
    //print(v);
    cout<<counter;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
    char a;
    int ans,r,c,h[15]={0},l[15]={0},x=0,y=0;
    cin>>r>>c;
    for(int i=1;i<=r;i++)
        for(int j=1;j<=c;j++)
        {
			cin>>a;
            if(a=='S'){h[i]=1;l[j]=1;}
        }
    for(int i=1;i<=15;i++)
    {
        if(h[i]==1)x++;
        if(l[i]==1)y++;
    }
    ans=r*c-x*y;
    cout<<ans;
    return 0;
}

#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n,m,cnt=0,cnt1=0;
    cin>>n>>m;
    char a[n+2][m+2];
    int p[n+2][m+2]= {0};
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m ; j++)
        {
            cin>>a[i][j];

        }
    }
    for(int i=0; i<n; i++)
    {
        int count=0;
        for(int j=0; j<m; j++)
        {
            if(a[i][j]=='.')
            {
                count++;
            }

        }
        //cout<<count<<endl;
        if(count==m)
        {
            for(int j=0; j<m; j++)
            {
                p[i][j]=1;
            }
        }
    }
    for(int i=0; i<m; i++)
    {
        int count=0;
        for(int j=0; j<n ; j++)
        {
            if(a[j][i]=='.')
                count++;
        }
        if(count==n)
        {
            for(int j=0; j<n; j++)
            {
                p[j][i]=1;
            }
        }

    }
    int ans=0;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m ; j++)
        {
            if(p[i][j]==1)
                ans++;
        }

    }
    cout<<ans;

}

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <utility>
using namespace std;

int main(){
    int n, m, r = 0, c = 0,t;
    bool row = false;
    char arr[100][10];
    cin >> n >> m;

    for (int  i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> arr[i][j];
            if (arr[i][j] == 'S' && row == false){
                row = true;
            }
        }
        if (row == true){
            r++;
            row = false;
        }
    }

    for (int i = 0; i < m; i++){
        for (int j = 0; j < n; j++){
            if (arr[j][i] == 'S'){
                c++;
                break;
            }
        }
    }
    //t = (n*m) - (r*c);
    cout << (n*m) - (r*c);

    return 0;
}

#include <iostream>
#include <vector>
using namespace std ;
int main()
{
	int r , c ;
	char **arr ;
	cin>>r>>c ;
	arr = new char* [r] ;
	for( int i = 0 ; i < r ;i++)
	{
		arr[i] = new char [c] ;
	}
	for( int i = 0 ; i < r ; i++)
	{
		for( int j = 0 ; j< c ;j++ )
		{
			cin>>arr[i][j] ;
		}
	}

	int rn= 0 , cn = 0  ;
	int v[10]= {0}, h[10]={0} ;
	int ip  = 99999999;
	for(int i = 0 ; i< r ; i++)
	{
		for(int j = 0; j< c ; j++)
		{
			if(arr[i][j]=='S'){
				if(v[i]==0) rn++ ;
				v[i]++ ;
				if(h[j]==0) cn++;
				h[j]++;
			}

		}

	}

	cout<<r*c - rn*cn<<endl ;
	return 0 ;
}

#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <string>
#include <memory.h>
#include <map>
#define _USE_MATH_DEFINES
#include <math.h>
#include <list>
#include <fstream>
#include <time.h>
#include <iomanip>
#include <queue>
#include <stack>
#include <complex>
#include <limits.h>
//#include <assert.h>

using namespace std;

#define For(i,a,b,d) for (int i = (a); i != (b); i += d)
#define FORD(i,a,b) for (int i = (a); i >= b; i--)
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define REPD(i,n) for (int i = (n - 1); i >= 0; i--)
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
#define CLR(a,x) memset(a,x,sizeof(a))
#define debug(x) cout << #x << "=" << x << endl;
#define pb push_back
#define mp make_pair

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int mx[4] = {1, -1, 0, 0};
const int my[4] = {0, 0, 1, -1};

const int Inf = 2000000000;
const int Mi = 1000000007;
const int N = 100005;
const int K = 11;
const ld eps = 10e-6;
const ld PI = 2 * acos(0.0);
const ll InfLL = ll(Inf) * ll(Inf);

ll gcd(ll a, ll b) {
    if (!b) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
    return (a / gcd(a, b)) * b;
}

vector<string> a;
bool rb[20], cb[20];

//#define ONLINE_JUDGE
int main () {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int r, c;
    cin >> r >> c;
    a.resize(r);
    REP(i, r) {
        cin >> a[i];
        REP(j, c) {
            if (a[i][j] == 'S') {
                rb[i] = cb[j] = true;
            }
        }
    }
    int ans = 0;
    REP(i, r)
        REP(j, c)
            if (a[i][j] == '.' && (!rb[i] || !cb[j]))
                ans++;
    cout << ans;
    return 0;
}

#include<iostream>
using namespace std;
int main()
{
    char arr[100][100];
    bool a=false;
    int n,m;
    cin>>n>>m;
    int result =0;
    int rowcounter =0;
    for(int i=0;i<n;i++)
    {
        for(int z=0;z<m;z++)
        {
            cin>>arr[i][z];
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int z=0;z<m;z++)
        {
            if(arr[i][z]=='.')
            {
                a=true;
                continue;
            }
            else if(arr[i][z]=='S')
            {
                a=false;
                break;
            }
        }
        if(a==true)
        {
            rowcounter++;
            result+=m;
            a=false;
        }
    }
    for(int i=0;i<m;i++)
    {
        for(int z=0;z<n;z++)
        {
            if(arr[z][i]=='.')
            {
                a=true;
                continue;
            }
            else if(arr[z][i]=='S')
            {
                a=false;
                break;
            }
        }
        if(a==true)
        {
            result+=n;
            result-=rowcounter;
        }
    }
    cout<<result<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pllll> vpllll;
#define INF INT_MAX
#define UINF UINT_MAX
#define LLINF LLONG_MAX
#define ULLINF ULLONG_MAX
#define REP(i, a, b) for (int i = a; i < b; ++i)
#define REPI(i, a, b) for (int i = a; i <= b; ++i)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define memall(arr, x) memset(arr, x, sizeof arr)
#define sz(x) x.size()
#define all(x) x.begin(), x.end()
#define isOdd(x) (x&1)
#define isEven(x) (!(x&1))
int gcd(int a, int b) { return (!a ? b : gcd(b % a, a)); }
int lcm(int a, int b) { return (a * (b / gcd(a, b))); }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    char cake[20][20];
    int r, c, ans = 0;
    cin >> r >> c;
    rep(i, r)
        rep(j, c)
            cin >> cake[i][j];
    rep(i, r) {
        bool s = false;
        int cnt = 0;
        rep(j, c) {
            if (cake[i][j] == 'S') {
                s = true;
                break;
            }
            else if (cake[i][j] == '.')
                cnt++;
        }
        if (!s) {
            rep(j, c)
                if (cake[i][j] == '.')
                    cake[i][j] = '-';
            ans += cnt;
        }
    }
    rep(j, c) {
        bool s = false;
        int cnt = 0;
        rep(i, r) {
            if (cake[i][j] == 'S') {
                s = true;
                break;
            }
            else if (cake[i][j] == '.')
                cnt++;
        }
        if (!s) {
            rep(i, r)
                if (cake[i][j] == '.')
                    cake[i][j] = '-';
            ans += cnt;
        }
    }
    cout << ans;
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<cmath>
#include<memory.h>
#include<cctype>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<list>
#include<stack>
#include<utility>
#include<iomanip>
#include<bitset>
#include<vector>
#include<cassert>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<cstring>
#define N 1000010
#define MP make_pair
using namespace std;
typedef long long int ll;
typedef long double ld;
char gr[11][11];
int main()
{
	set<int>vi,vj;
	int r,c;
	scanf("%d%d",&r,&c);
	int x=0;
	for(int i=0;i<r;++i){
		for(int j=0;j<c;++j){
			scanf(" %c",&gr[i][j]);
			if(gr[i][j]=='S'){
				vi.insert(i);
				vj.insert(j);
			}
		}
	}
	//for(int i=0;i<vi.size();i++)cout <<vi[i]<<endl;
	printf("%d\n",(r*c)-(int(vi.size())*int(vj.size())));
	return  0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
    ll t,n,i,j;
    {
        ll r,c;
       cin>>r>>c;
       ll d;
       char ch[r][c];
       set<ll> ro,co;
       for(i=1;i<=r;i++)
       {
           for(j=1;j<=c;j++)
           {
               cin>>ch[i][j];
               if(ch[i][j]=='S')
                {
                    ro.insert(i);
                   co.insert(j);
                }
           }
       }
       d=(r-ro.size())*c+(c-co.size())*r-(r-ro.size())*(c-co.size());
        if(d<0)
            cout<<0<<endl;
        else
        cout<<d<<endl;
	}
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
string s[10];
int main()
{
    int r, c;
    int x, y;
    x = y = 0;
    cin >> r >> c;
    for(int i = 0; i < r; i ++)
        cin >> s[i];
    for(int i = 0; i < r; i ++) {
        int j = 0;
        for(j = 0; j < c; j ++) {
            if(s[i][j] == 'S')
                break;
        }
        if(j == c)
            x ++;
    }
    for(int j = 0; j < c; j ++) {
        int i = 0;
        for(i = 0; i < r; i ++) {
            if(s[i][j] == 'S')
                break;
        }
        if(i == r)
            y ++;
    }
    cout << x * c + y * r - x * y;
    return 0;
}

//phoenix

#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define spdio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pp pop_back
#define mp make_pair
//getline(cin,string);
const ll inf = (ll) 1e18 + 19;

void cazz() {
    ll t,n,i,j,m,k;
    ll r,c,cnt=0,cnt1=0,cnt2=0;
    cin>>r>>c;
    char a[r][c];
    for(i=0; i<r; i++) {
        for(j=0; j<c; j++) {
            cin>>a[i][j];
        }
    }
    for(i=0; i<r; i++) {
        for(j=0; j<c; j++) {
            if(a[i][j]!='S')
                cnt++;
            if(cnt==c)
                cnt1++;
            if(cnt==c || j==c-1)
                cnt=0;
        }
    }
    cnt=0;
    for(i=0; i<c; i++) {
        for(j=0; j<r; j++) {
            if(a[j][i]!='S')
                cnt++;
            if(cnt==r)
                cnt2++;
            if(cnt==r || j==r-1)
                cnt=0;
        }
    }
    cnt=((cnt1*c)+(cnt2*r))-cnt1*cnt2;
    cout<<cnt<<"\n";
}

int main() {
    spdio;
	cazz();
	return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <utility>
#include <iterator>
#include <string>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;

#ifdef TESTING
#define DEBUG fprintf(stderr, "====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define DEBUG
#define VALUE(x)
#define debug(...)
#endif

#define IOS ios_base::sync_with_stdio(false);\
        cin.tie(0);\
        cout.tie(0);
#define endl "\n"
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a) = (b); (a) >= (c); --(a))
#define FORSQ(a, b, c) for (int(a) = (b); (a) * (a) <= (c); ++(a))
#define FORC(a, b, c) for (char(a) = (b); (a) <= (c); ++(a))
#define FOREACH(a, b) for (auto&(a) : (b))
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PERMUTE next_permutation
#define tc(t) while (t--)
#define min(a,b,c) a<b?(a<c?a:c):(b<c?b:c)
#define max(a,b,c) a>b?(a>c?a:c):(b>c?b:c)
int main()
{
	IOS;
	int n,k,count,count1=0,count2,count3=0;
	cin>>n>>k;
	vector< vector< char > > m(n,vector< char >(k));
	rep(i,n)
	{
		rep(j,k)
		{
			cin>>m[i][j];

		}
	}
	rep(i,n)
	{
		count=0;
		rep(j,k)
		{
			if(m[i][j]=='.')
				count++;
		}
		if(count==k)
			count1++;//row
	}
	rep(j,k)
	{
		count2=0;
		rep(i,n)
		{
			if(m[i][j]=='.')
				count2++;
		}
		if(count2==n)
			count3++;//column
	}
	cout<<count1*k+count3*n-(count1*count3);
	return 0;
}

#include <iostream>
#include <vector>
#include <set>

using namespace std;

set <int> v,t;
char a[11][11];
int n,m,sum,cnt;
int main()
{
    cin >> n >> m;
    sum = n*m;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= m; ++j)
        {
            cin >> a[i][j];
        }
    }
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= m; ++j)
        {
            if (a[i][j] == 'S')
            {
                v.insert(i);
                t.insert(j);
            }
        }
    }
    cout << sum - (v.size()*t.size());
}

#include <stdio.h>
#include <stdlib.h>
int arrrow[1000],arrcol[1000];
int main()
{
int row,col,i,j;scanf("%d%d",&row,&col);
char a[row][1000];
for(i=0;i<row;i++)scanf("%s",a[i]);

for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
 if(a[i][j]=='S')
 {
  arrrow[i]=1;
  arrcol[j]=1;
 }
}
}

     int xrow=0,xcol=0;
for(i=0;i<row;i++)
if(arrrow[i]!=1)xrow++;

if(xrow==row){printf("%d\n",col*row);return 0;}

for(i=0;i<col;i++)
if(arrcol[i]!=1)xcol++;
printf("%d\n",xrow*col+xcol*(row-xrow));

    return 0;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <limits>
#include <cmath>
#include <cstdlib>
#include <string.h>
#include <ctime>

using namespace std;

#define VI vector<int>
#define VVI vector<VI >
#define VB vector<bool>
#define VVB vector<VB >
#define VC vector<char>
#define VVC vector<VC >
#define VS vector<string>
#define PII pair<int, int>
#define VPII vector<pair<int, int> >
#define REP(var, startFrom, endTo) for(int var = startFrom; var < (int)endTo; ++var)

template <typename T>
inline const T MAX(T a, T b) { return ((a) > (b) ? (a) : (b)); }
template <typename T>
inline const T MIN(T a, T b) { return ((a) > (b) ? (b) : (a)); }
template <typename T>
inline const T ABS(T a) { return (((a) > 0) ? (a) : (-(a))); }

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	int row, col;
	cin >> row >> col;

	VVC cake = VVC(row, VC(col));

	int ans = 0, uRow = 0, uCol = 0;
	for (int i = 0; i < row; ++i)
	{
		bool checked = false;
		for (int j = 0; j < col; ++j)
		{
			cin >> cake[i][j];
			if (cake[i][j] == 'S' && !checked)
			{
				checked = true;
				++uCol;
			}
		}
	}
	for(int i = 0; i < col; ++i)
		for (int j = 0; j < row; ++j)
		{
			if (cake[j][i] == 'S')
			{
				++uRow;
				break;
			}
		}

	cout << (row * col) - (uRow * uCol) << endl;

	/*VVC cake = VVC(row, VC(col, '.'));
	VB strawberryCol = VB(10, false);

	int cnt = 0;
	REP(i, 0, row)
	{
		bool strawberry = false;
		REP(j, 0, col)
		{
			cin >> cake[i][j];
			if (cake[i][j] == 'S')
			{
				strawberryCol[j] = true;
				strawberry = true;
			}
		}
		if (!strawberry)
		{
			cnt += col;
			cake[i] = VC(col, 'E');
		}
	}

	for (int x = 0; x < col; ++x)
	{
		if (strawberryCol[x])
			continue;
		for (int y = 0; y < row; ++y)
		{
			if(cake[y][x] == 'E')
				continue;
			++cnt;
		}
	}

	cout << cnt << endl;*/

	return 0;
}

#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    char a[20][20];
    int i,j,m,n;
    cin>>m>>n;
    for(i=0;i<m;i++)
    {
        for(j=0;j<n;j++)
        {
            cin>>a[i][j];
        }
    }
    int ans=0,col=0,row=0,cnt=0;
    for(i=0;i<m;i++)
    {
        cnt=0;
        for(j=0;j<n;j++)
        {
            if(a[i][j]!='S')
            {
                cnt++;
            }
        }
        if(cnt==n)
        {
            row+=1;
            ans=ans+cnt;
        }
    }
    for(i=0;i<n;i++)
    {
        cnt=0;
        for(j=0;j<m;j++)
        {
            if(a[j][i]!='S')
            {
                cnt++;
            }
        }
        if(cnt==m)
        {
            col+=1;
            ans=ans+cnt;
        }
    }
    ans=ans-(row*col);
    cout<<ans<<endl;
}

#include <iostream>
#include <bits/stdc++.h>
#include <mutex>
#include <thread>
#include <chrono>

using namespace std;
using namespace std::chrono;

int main()
{
   int r, c;
   cin >> r >> c;

   bool cov[r][c] = {false};
   vector<bool> vr(r, false), vc(c, false);
   char e;
   for (int i = 0; i < r; ++i) {
      for (int j = 0; j < c; ++j) {
         cin >> e;
         if(e == 'S') {
            vr[i] = true;
            vc[j] = true;
         }
         cov[i][j] = false;
      }
   }

   uint32_t ans = 0;

   // check rows
   for (int i = 0; i < r; ++i)
   {
      if(vr[i]) continue;
      ans += c;
      for_each(cov[i], cov[i] + c, [](bool &e){e = true;});
   }

   // cover columns
   for (int i = 0; i < c; ++i) {
      if(vc[i]) continue;
      for (int j = 0; j < r; ++j) {
         if(!cov[j][i]) {++ans;}
      }
   }

   cout << ans << "\n";
   return 0;
}

#include <iostream>
#include <string>
using namespace std;
bool NgR[10],NgC[10],pos[10][10];
int main(){
    int n,m,r=0;
    cin >> n >> m;
    char c[10][10];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> c[i][j];
            if(c[i][j]=='S'){
                NgR[i]=true;
                NgC[j]=true;
            }
        }
    }

    for(int i=0;i<m;i++){
        if(!NgC[i]){
            for(int j=0;j<n;j++){
                if(pos[j][i]==false){
                    r++;
                    pos[j][i]=true;
                }
            }
        }
    }

    for(int i=0;i<n;i++){
        if(!NgR[i]){
            for(int j=0;j<m;j++){
                if(pos[i][j]==false){
                    r++;
                    pos[i][j]=true;
                }
            }
        }
    }
    cout << r;
}

#include <iostream>

using namespace std;

int main()
{
    int r,c,cc=0,sum=0,row=0,colum=0; cin>>r>>c;
    char arr[r][c];
    int checkr[10]={0};
    int checkc[10]={0};
    for (int i=0;i<r;i++) {
        for (int j=0;j<c;j++) {
            cin>>arr[i][j];
        if (arr[i][j]=='S') {checkr[i]=1; checkc[j]=1;}
        }
    }
    for (int i=0;i<r;i++) {
        if (checkr[i]==0) {row+=c; cc++;}
        }
    for (int j=0;j<c;j++) {
        if (checkc[j]==0) {colum+=(r-cc);}
        }
    cout<<row+colum<<endl;
    return 0;
}

#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    int r, c, answ = 0;
    cin >> r >> c;
    vector <string>a(r);
    for (int i = 0; i < r; i++) {
        cin >> a[i];
    }
    bool berry = false;
    for (int i = 0; i < r; i++) {
        berry = false;
        for (int j = 0; j < c; j++) {
            if (a[i][j] == 'S')berry = true;
        }
        if (!berry) {
            for (int j = 0; j < c; j++) {
                a[i][j] = ' ';
                answ++;
            }
        }
    }

    for (int j = 0; j < c; j++) {
        berry = false;
        for (int i = 0; i < r; i++) {
            if (a[i][j] == 'S')berry = true;
        }
        if (!berry) {
            for (int i = 0; i < r; i++) {
                if(a[i][j] != ' ')answ++;
                a[i][j] = ' ';
            }
        }
    }
    cout << answ;
    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <cstring>
#include <stack>

#define VI vector <int>
#define VS vector <string>
using namespace std;

int main() {
    int r, c;
    scanf("%d %d\n",&r,&c);
    bool rr[11], cc[11];
    for(int i = 0; i < 11; i++) {rr[i] = cc[i] = true;}
    for(int i = 0; i < r; i ++)
      for(int j = 0; j < c; j++){
        char ch ; cin >> ch;
        if(ch == 'S') {rr[i] = false; cc[j] = false;}
    }
    int x = 0, y = 0;
    for(int i = 0; i < r; i++) if(rr[i]) x++;
    for(int i = 0; i < c; i++) if(cc[i]) y++;
    printf("%d\n",x * c + y * r - x * y);
return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define ll long long int
#define vec vector<int>
#define str string
#define get_ cin.get()

using namespace std;

int main()
{
	int r, c;
	cin >> r >> c;
	vector<string> v;
	while (r--) {
		string s;
		cin >> s;
		v.push_back(s);
	}
	int count = 0;
	int rows_with_s = 0;
	for (int i = 0; i < v.size(); ++i) {
		bool ok = true;
		for (int j = 0; j < v[i].size(); ++j) {
			if (v[i][j] == 'S') {
				ok = false;
				break;
			}
		}
		if (ok) { count += v[i].size(); rows_with_s++; }
	}
	for (int i = 0; i < v[0].size(); ++i) {
		bool ok = true;
		for (int j = 0; j < v.size(); ++j) {
			if (v[j][i] == 'S') {
				ok = false;
				break;
			}
		}
		if (ok) {
			count += v.size() - rows_with_s;
		}
	}
	cout << count << endl;

}

#include <iostream>

using namespace std;

int main()
{
    int n,m;
    cin >> n >> m;
    string a[n];
    bool col[m];
    bool row[n];
    for (int i = 0 ; i<m ; i++) {
        col[i] = false;
    }
    for (int r = 0 ; r<n ; r++) {
        row[r] = false;
        cin >> a[r];
        for (int c = 0 ; c<m ; c++) {
            if (a[r][c] == 'S') {
                col[c] = true;
                row[r] = true;
            }
        }
    }
    int mmd = 0;
    int cnt = 0;
    for (int i = 0 ; i<n ; i++) {
        if (!row[i]) {
            cnt += m;
            mmd++;
        }
    }
    for (int i = 0 ; i<m ; i++) {
        if (!col[i]) {
            cnt += n-mmd;
        }
    }
    cout << cnt;
    return 0;
}

#include<iostream>

using namespace std;

int rowsEaten=0;
char grid[10][10];

int main()
{
	int r,c,i,j,ans=0;
	cin >> r >> c;
	for(i=0;i<r;i++)
		for(j=0;j<c;j++)
			cin >> grid[i][j];

	for(i=0;i<r;i++)
	{
		for(j=0;j<c;j++)
			if(grid[i][j]=='S')
				break;
		if(j==c)
		{
			ans += c;
			rowsEaten++;
		}
	}

	for(i=0;i<c;i++)
	{
		for(j=0;j<r;j++)
			if(grid[j][i]=='S')
				break;
		if(j==r)
			ans += r - rowsEaten;
	}

	cout << ans << endl;
	return 0;
}

#include<iostream>
#include<string>
using namespace std;
int main()
{
    bool row[16] = {}, column[16] = {};
    char x;
    int n, m,Row=0,Column=0;
    cin >> n >> m;
    //nxm
    for (int i = 0; i < n; i++)
        for (int j = 0;j<m;j++)
        {
            cin >> x;
            if (x == 'S')
            {
                if (!row[i])
                {
                    row[i] = true;
                    Row++;

                }
                if (!column[j])
                {
                    column[j] = true;
                    Column++;
                }
            }
        }
    cout << n*m - Row*Column << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    char a[n][m];
    set <int> row;
    set <int> column;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>a[i][j];
            if(a[i][j]=='S')
            {
                row.insert(i);
                column.insert(j);
            }
        }
    }
    cout<<(n*m)-(row.size()*column.size());
    return 0;
}

#include <iostream>
#include <cstring>
#include <conio.h>
#include <cmath>

using namespace std;
int omadliRaqamlarSoni(int n);
int main(int argc, char** argv) {
	int n, m, i, j, k = 0;
	bool t[11][11], t1;
	cin>>n>>m;
	for(i = 1;i<=10;i++){
		for(j = 1;j<=10;j++){
			t[i][j] = false;
		}
	}
	char s[11][11];
	for(i = 1;i<=n;i++){
		t1 = false;
		for(j = 1;j<=m;j++){
			cin>>s[i][j];
			if(s[i][j] == 'S'){
				t1 = true;
			}
		}
		if(!t1){
			k++;
			for(j = 1;j<=m;j++){
				t[i][j] = true;
			}
		}
	}
		int soni = 0;
	for(i = 1;i<=n;i++){
		for(j = 1;j<=m;j++){
			if(t[i][j]){
				soni++;
			}
		}
	}
	for(i = 1;i<=m;i++){
		t1 = false;
		for(j = 1;j<=n;j++){
			if(s[j][i] == 'S'){
				t1 = true;
			}
		}
		if(!t1){
			soni-=k;
			for(j = 1;j<=n;j++){
				t[j][i] = true;
			}
		}else{
			for(j = 1;j<=n;j++){
				t[j][i] = false;
			}
		}
	}
	for(i = 1;i<=n;i++){
		for(j = 1;j<=m;j++){
			if(t[i][j]){
				soni++;
			}
		}
	}
	cout<<soni;

	return 0;
}
/*int omadliRaqamlarSoni(int n){
	int turt_soni = 0, yet_soni = 0;
	while(n!=0){
		if(n%10 == 4){
			turt_soni++;
		}
		if(n%10 == 7){
			yet_soni++;
		}
		n= n/10;
	}
	return turt_soni+yet_soni;
}*/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <assert.h>
#include <cctype>
#include <string.h>
using namespace std;

#define INF_MAX 2147483647
#define INF_MIN -2147483647

#define pi acos(-1.0)
#define INF 1e9
#define ll long long

#define For(i, a, b) for( int i = (a); i < (b); i++ )
#define Fors(i, sz) for( size_t i = 0; i < sz.size (); i++ )
#define Fore(it, x) for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
#define mem(a, s) memset(a, s, sizeof (a))
#define Read() freopen("1.txt", "r", stdin)
#define Write() freopen("2.txt", "w", stdout)
#define sz(c) ((int)(c).size())
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vl vector<ll>
#define vll vector<vector <ll> >
typedef pair<int, int> PAIR;
typedef pair<PAIR, int> PAIR2;
string tostring(long long n){ ostringstream ss; ss << n; return ss.str(); }
ll tonumber(string str){ stringstream ss; ss << str; long long n; ss >> n; return n; }

int main()
{

    int n, m, res = 0, cnt = 0;
    bool b = true;
    string s;

    cin >> n >> m;
    vector<string> v;
    For(i, 0, n)
    {
        cin >> s;
        v.push_back(s);
        if (count(v[i].begin(), v[i].end(), 'S') == 0)
        {
            For(j, 0, m)
            {
                if (v[i][j] == '.')
                {
                    v[i][j] = 'e';
                    res++;
                }
            }
        }

    }
    For(j, 0, m)
    {
            For(i, 0, n)
            {
                if (v[i][j] == 'S')
                {
                    b = false;
                    break;
                }
                else if (v[i][j] == '.')
                    cnt++;

            }
            if (b == true)
                res += cnt;
            b = true;
            cnt = 0;

    }
    cout << res << endl;

}

#include<iostream>

using namespace std;

bool Isempty(char**&,int,int);
void Eat(char**&,int,int);
bool Isempty1(char**& ,int ,int );
void Eat1(char**& A,int,int );
int main()
{

    int r,c;
    cin >> r >> c;
    char **A = new char *[r];
    for (int i = 0; i < r; i++)
    {
        *(A+i) = new char [c];
    }
    for (int i = 0; i < r; i++)
        for (int j = 0; j < c; j++)
            cin >> A[i][j];

    int i = 0;
    do
    {
    for (int j = 0; j < c; j++)
    {
        if (A[i][j] == '.')
            if (Isempty(A,j,r))
                Eat(A,j,r);
    }
    i++;
    }while (i < r);

    int l = 0;
    do
    {
    for (int m = 0; m < r; m++)
    {
        if (A[m][l] == '.')
            if (Isempty1(A,m,c))
                Eat1(A,m,c);
    }
    l++;
    }while (l < c);

    int count = 0;
    for (int x = 0; x < r; x++)
        for (int y = 0; y < c; y++)
            if (A[x][y] == '*')
                count++;

    cout << count;

    return 0;
}
bool Isempty(char**& A,int a,int x)
{
    for (int k = 0; k < x; k++)
        if (A[k][a] == 'S')
            return false;
    return true;
}
void Eat(char**& A,int a,int x)
{
    for (int k = 0; k < x; k++)
        A[k][a] = '*';
}
bool Isempty1(char**& A,int a,int x)
{
    for (int k = 0; k < x; k++)
        if (A[a][k] == 'S')
            return false;
    return true;
}
void Eat1(char**& A,int a,int x)
{
    for (int k = 0; k < x; k++)
        A[a][k] = '*';
}

#include "iostream"
using namespace std;
int main()
{
	int str, stl;
	cin >> str >> stl;
	char mass[100][100];
	for (int i = 0; i < str; i++)
	{
		cin >> mass[i];
	}
	int schet = 0;
	int schet1 = 0;
	for (int i = 0; i < str; i++)
	{
		for (int j = 0; j < stl; j++)
		{
			if (mass[i][j] != 'S')schet = 1;
			else
			{
				schet = 0;
				break;
			}
		}
		if (schet != 0)
		{
			for (int j = 0; j < stl; j++)
			{
				if (mass[i][j] == '.')
				{
					schet1++; mass[i][j] = '0';
				}
			}
		}
	}
	schet = 0;
	for (int j = 0; j < stl; j++)
	{
		for (int i = 0; i < str; i++)
		{
			if (mass[i][j] != 'S')schet = 1;
			else
			{
				schet = 0;
				break;
			}
		}
		if (schet != 0)
		{
			for (int i = 0; i < str; i++)
			{
				if (mass[i][j] == '.')
				{
					schet1++; mass[i][j] = '0';
				}
			}
		}
	}
	cout << schet1 << endl;
	return 0;
}

#include<iostream>
int main()
{
	int r, c, rf[10] = {0}, cf[10] = {0};
	char g;
	std::cin >> r >> c;
	for (int i = 0; i < r; ++i) {
		for (int j = 0; j < c; ++j) {
			std::cin >> g;
			if (g == 'S') cf[j] = rf[i] = 1;
		}
	}
	g = r * c;
	for (int i = 0; i < r; ++i)
		for (int j = 0; j < c; ++j) g -= rf[i] && cf[j];
	std::cout << (int)g;
	return 0;
}

#include<stdio.h>
#include<string.h>
int rowchecker(char [15][15],int,int,int);
int colchecker(char [15][15],int,int,int);
int n;
main()
{
	char s[15][15];
	int i,j,r,c,res1,res2,count=0;
	scanf("%d %d",&r,&c);
	for(i=0;i<r;i++)
	scanf(" %[^\n]",s[i]);
	for(i=0;i<r;i++)
	{
		res1=0;
		res1=rowchecker(s,r,c,i);
		if(res1==1)
		{
			for(j=0;j<c;j++)
			s[i][j]='0';
		}
	}
	for(j=0;j<c;j++)
	{
		res2=0;
		res2=colchecker(s,r,c,j);
		if(res2==1)
		{
			for(i=0;i<r;i++)
			s[i][j]='0';
		}
	}
	for(i=0;i<r;i++)
	{
		for(j=0;j<c;j++)
		{
			if(s[i][j]=='0')
			count++;
		}
	}
	printf("%d\n",count);
}
int rowchecker(char s[15][15],int r,int c,int n)
{
	int j;
	for(j=0;j<c;j++)
	{
		if(s[n][j]=='S')
		break;
	}
	return(j==c?1:0);
}
int colchecker(char s[15][15],int r,int c,int n)
{
	int i;
	for(i=0;i<r;i++)
	{
		if(s[i][n]=='S')
		break;
	}
	return(i==r?1:0);
}

#include <iostream>
#include <vector>

using namespace std;

int main(){
	int r,c,mn=0,bb=0,okr,okc;
	cin >> r >> c;
	char tmp;
	int arr[r+5][c+5];
	int sr[15]={0};
	int sc[15]={0};
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			cin >> tmp;
			if(tmp=='S'){
				sr[i]=1;
				sc[j]=1;
				arr[i][j]=1;
				bb++;
			}else{
				arr[i][j]=0;
			}

		}
	}

	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			if(arr[i][j]!=1&&sc[j]==1&&sr[i]==1) mn++;

		}
	}

	//cout << arr[2][3] << endl;
	//cout << bb << endl;
	//cout << mn << endl;
	cout << r*c-bb-mn << endl;
	return 0;
}

#include<bits/stdc++.h>
#include<string>
using namespace std;
void PLAY() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(4);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int main()
{

int r, c, row[11] = {0}, col[11] ={0};
    string s;
    cin >> r >> c;
    for (int i = 0; i < r; ++i)
    {
        cin >> s;
        for (int j = 0; j < c; ++j)
        {
            if (s[j] == 'S')
            {
                row[i] = 1;
                col[j] = 1;
            }
        }
    }
    int cakes(0);
    for (int i = 0; i < r; ++i)
    {
        for (int j = 0; j < c; ++j)
        {
            if (row[i] == 0 || col[j] == 0)
            {
                cakes += 1;
            }
        }
    }
    cout << cakes << endl;
    return 0;
}

// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
//

#include<bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define int long long int
#define ld long double
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define r0 return 0;
#define tc int t;cin>>t;while(t--)
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define vi vector<int>
#define vii vector<long long int>
#define SORT(v) sort(v.begin(),v.end());
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define md 998244353
#define inf 1000000000000000 //1e15
#define gcd __gcd
#define lcm(a,b) ((a)*(b))/gcd(a,b)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define crap ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
int min(int a,int b){
    return (a<b)?a:b;
}
int max(int a,int b){
    return (a>b)?a:b;
}
int fp(int a,int b){
    if(b==0) return 1;
    int x=fp(a,b/2);
    x=(x*x)%mod;
    if(b&1) x=(x*a)%mod;
    return x;
}
int factorial(int n)
{
    int fact=1;
    for(int i=2;i<=n;i++)
    fact=fact*i;

    return fact;
}
int ncr(int n,int r)
{
    return factorial(n)/(factorial(r)*factorial(n-r));
}
int binomialCoeff(int n,int k)
{
    int dp[k+1];
    memset(dp,0,sizeof(dp));
    dp[0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=min(i,k);j>0;j--)
        dp[j]=(dp[j]+dp[j-1])%mod;
    }
    return dp[k]%mod;

}
void c_p_c()
{
    crap;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
signed main()
{
    c_p_c();
    int n,m;
    cin>>n>>m;
    int row[n]={0};
    int col[m]={0};
    for(int i=1;i<=n;i++)
    {
        string s;
        cin>>s;
        for(int j=0;j<m;j++)
        {
            if(s[j]=='S')
            {
                row[i]=1;
                col[j]=1;
            }
        }
    }
    int x=0,y=0;
    for(int i=1;i<=n;i++)
        if(row[i]==1)
            x++;
    for(int j=0;j<m;j++)
        if(col[j]==1)
            y++;
    cout<<(n*m)-(x*y)<<endl;
}

#include"iostream"
using namespace std;

struct CHAR
{
	char s;
};
bool KTHang(CHAR a[], int n)
{
	for (int i = 0; i < n; i++)
	{
		if (a[i].s == 'S')
			return false;
	}
	return true;
}
bool KTCot(CHAR a[][10], int vtcot, int sodong)
{
	for (int i = 0; i < sodong; i++)
	{
		if (a[i][vtcot].s == 'S')
			return false;
	}
	return true;
}
int main()
{
	CHAR a[10][10];
	int r, c;
	int dem = 0;
	cin >> r >> c;
	for (int i = 0; i < r; i++)
	{
		for (int j = 0; j < c; j++)
		{
			cin >> a[i][j].s;
		}
	}
	for (int i = 0; i < r; i++)
	{
		if (KTHang(a[i], c))
		{
			for (int j = 0; j < c; j++)
			{
				a[i][j].s = '1';
				dem++;
			}
		}
	}
	for (int j = 0; j < c; j++)
	{
		if (KTCot(a, j, r))
		{
			for (int i = 0; i < r; i++)
			{
				if (a[i][j].s == '.')
				{
					dem++;
					a[i][j].s = '1';
				}
			}
		}
	}
	cout << dem;
}

#include <iostream>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

set <int> str;
set <int> stl;

int main(){

    int r,c, sum=0;
    char s;

    cin>>r>>c;

    for(int i=0; i < r; i++){
        for(int j=0; j < c; j++){
            cin>>s;
            if(s == 'S'){
                str.insert(i);
                stl.insert(j);
            }
        }
    }
    sum = r*c;

    cout<< sum - str.size()*stl.size();

    return 0;
}

#include <iostream>
using namespace std;

int main() {
    char a[10][10];
    int r,c,i,j,n=0,ctr=0,ctc=0,R,C;
    cin>>r>>c;
    for(i=0;i<r;i++)
        for(j=0;j<c;j++)
            cin>>a[i][j];
    for(i=0;i<r;i++)
    {
        for(j=0;j<c;j++)
            if(a[i][j]=='S')
                {
                ctr++;
                break;
                }
    }
    for(i=0;i<c;i++)
        {
            for(j=0;j<r;j++)
                if(a[j][i]=='S')
                    {
                    ctc++;
                    break;
                    }
        }
    R=r-ctr;
    C=c-ctc;
    n=R*c+C*r-C*R;
    cout<<n;
    return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int r,c,i,j;
    char a[15][15];
    cin>>r>>c;
    for(i=0;i<r;i++)
    {
        for(j=0;j<c;j++)
        {
            cin>>a[i][j];
        }
    }
    int p=0;
    for(i=0;i<r;i++)
    {
        for(j=0;j<c;j++)
        {
            if(a[i][j]=='S')
            {
                p++;
                break;
            }
        }
    } int s=0;
    for(i=0;i<r;i++)
    {
        for(j=0;j<c;j++)
            if(a[i][j]=='S')
            s++;
    }
    int q=0;
     for(i=0;i<r;i++)
    {
        for(j=0;j<c;j++)
        {
            if(a[j][i]=='S')
            {
                q++;
                break;
            }
        }
    }
    int z=(r*c)-(p*c)+(r*c)-(q*r)-s;
    if(z<0)
        cout<<0;
        else if(p==r)
            cout<<r*c-q*r;
        else if(q==c)
            cout<<r*c-p*c;
    else if(z<r*c)
        cout<<z;
    else
        cout<<r*c;
}

#include <stdio.h>
#include <stdlib.h>
//for(i=0;i<row;i++){for(j=0;j<col;j++){printf("%c-",a[i][j]);}printf("\n");}
int arrrow[1000],arrcol[1000];
int main()
{
int row,col,i,j;scanf("%d%d",&row,&col);
char a[row][1000];
for(i=0;i<row;i++)scanf("%s",a[i]);

for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
 if(a[i][j]=='S')
 {
  arrrow[i]=1;
  arrcol[j]=1;
 }
}
}
     int xrow=0,xcol=0;
//*************************************
for(i=0;i<row;i++)
if(arrrow[i]!=1)xrow++;

if(xrow==col){printf("%d\n",col*row);return 0;}

for(i=0;i<col;i++)
if(arrcol[i]!=1)xcol++;
//printf("%d %d %d %d\n",xcol,col,xrow,row);
printf("%d\n",xrow*col+xcol*(row-xrow));

    return 0;
}

#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int main()
{
    int row[1000];
    int col[1000];
    char arr[1000][1000];
    int s = 0;
    int count = 1;
    int r, c;
    cin >> r >> c;
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            cin >> arr[i][j];
            if (arr[i][j] == 'S')
            {
                row[s] = i;
                col[s] = j;
                s++;
            }
        }
    }
    sort(row, row + s);
    sort(col, col + s);
    for (int i = 0; i < s; i++)
    {
        if (i + 1 <= s && row[i] == row[i + 1])
            count++;
        if (i + 1 <= s && col[i] == col[i + 1])
            count++;
    }
    if (count >= s)
    {
        if (r*c / 2 == count)
            cout << "0";
        else
            cout << (r*c) - s;
    }
    else
        cout << (r*c) - s * 2;

}

#include <bits/stdc++.h>
#include <iostream>

//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

using namespace std;

int main() {

    int n,m;
    cin >> n >> m;
    int cnt = 0;
    bool row[n],column[m];
    char c[n+1][m+1];

    for(int i = 0; i<n; i++){
        for(int j = 0; j<m; j++){
            cin >> c[i][j];
            if(c[i][j] == 'S'){
                row[i] = true;
                column[j] = true;
            }
        }
    }

    for(int i = 0; i<n; i++){
        for(int j = 0; j<m; j++){
            if(!row[i] || !column[j])cnt++;
        }
    }

        cout << cnt;
}

#include<iostream>
#include<string>
using namespace std;

int main() {
    int rows,columns;
    cin >> rows >> columns;
    bool r[rows+1];
    bool c[columns+1];
    string str;
    for(int i = 1; i <= rows; i++) {
        cin >> str;
        for(int j = 1; j <= columns; j++) {
            if(str[j-1]!='.') {
                r[i] = true;
                c[j] = true;
            }
        }
    }
    int sum = 0, nre = 0;
    for(int i = 1; i <= rows; i++) {
        if(!r[i]) {
            sum += columns;
            nre++;
        }
    }
    if(rows>nre) {
        int temp = rows - nre;
        for(int i = 1; i <= columns; i++) {
            if(!c[i]) {
                sum += temp;
            }
        }
    }
    cout << sum;
    return 0;
}

#include <cstring>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <cmath>
#include <cstdio>
#include <set>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    char a[n][m];
    int count = 0;
    int i ,j;
    bool a1[n],a2[m];
    memset(a1,false,n);
    memset(a2,false,m);
    for ( i = 0 ; i < n; i++){
        for ( j = 0 ; j < m ; j++){
            cin >> a[i][j];

        }
    }

    int sum1 = 0, sum2 = 0;
    for ( i = 0 ; i < n ; i++){
        for ( j = 0 ; j < m ; j++){
            if ( a[i][j] == 'S' ){
                sum1++;
                break;
            }
        }

    }
//  cout << sum1 << endl;
    count = 0;
    for ( j= 0 ; j< n ; j++){
        for ( i = 0 ; i < m ; i++){
            if ( a[j][i] == 'S' ){
                    sum2++;
                    break;
            }
        }

    }
//  cout << sum2 << endl;
    int mul = sum1 * sum2;
    int out = (n*m) - mul;
    cout << out << endl;
/*  int mul1 = n * m;
    int mul2 = pow( count , 2);
//  cout << mul2 << endl;
    int out = mul1 - mul2;
    cout << out << endl;
*/

    return 0;
}

#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
#include <string>
#include <deque>
#include <set>
#include <bitset>
#include <sstream>
#include <map>

using namespace std;

typedef long long int64;

int main(){
	int n, m;
	cin >> n >> m;
	vector<string> vecStrs;
	string str;
	for (int i = 0; i < n; ++i)
	{

		cin >> str;
		vecStrs.push_back(str);
	}
	int answer = 0, s = 0;
	for (int i = 0; i < vecStrs.size(); ++i)
	{
		str.clear();
		str = vecStrs[i];
		answer+= str.size();
		for (int j = 0; j < str.size(); ++j)
		{
			if (str[j] == 'S')
				s++;
		}
	}
	answer = answer - s * 2;
	if (answer <= 0)
		cout << 0 << endl;
	else
		cout << answer << endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int i,j,n,m,k,b,c,x=0,y=0,z;
    char a[15][15];
    scanf ("%d%d",&n,&m);
    for (i=0;i<n;i++){
        for (j=0;j<m;j++){
            scanf ("%c",&a[i][j]);
            if (a[i][j]=='\n')
                j--;
        }
    }
    for (i=0;i<n;i++){
        b=x;
        for (j=0;j<m;j++){
            if (a[i][j]=='S'){
                x=b;
                break;
            }
            else{
                x+=1;
            }
        }
    }
    for (i=0;i<m;i++){
        c=y;
        for (j=0;j<n;j++){
            if (a[j][i]=='S'){
                y=c;
                break;
            }
            else{
                y+=1;
            }
        }
    }
    if (x==y)
        y=0;
    else{
        z=y/n;
        y-=z;
    }
    printf ("%d",x+y);
    //printf ("%d",y);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
      int r,c;
      cin>>r>>c;

      char a[r][c];

      int col[c]={0};

      int row[r]={0};

      for(int i=0;i<r;i++)
      {
            for(int j=0;j<c;j++)
            {
                  cin>>a[i][j];

                  if(a[i][j]=='S')
                  {
                        row[i]=1;
                        col[j]=1;
                  }
            }
      }

      bool visited[r][c];

      memset(visited,sizeof(visited),false);

      int count=0;

      for(int i=0;i<r;i++)
      {
            if(row[i]==0)
            {
                  for(int x=0;x<c;x++)
                  {
                        if(visited[i][x]==false)
                        {
                              count++;
                              visited[i][x]=true;
                        }
                  }
            }
      }

      for(int j=0;j<c;j++)
      {
            if(col[j]==0)
            {
                  for(int x=0;x<r;x++)
                  {
                        if(visited[x][j]==false)
                        {
                              count++;
                              visited[x][j]=true;
                        }
                  }
            }
      }

      cout<<count;
}

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  int r,c,flag=0; vector <int> row, col;
  cin>>r>>c;
  for(int i=0;i<r;i++) //rows
  for(int j=0;j<c;j++) //columns
  { char A[1][1];
    cin>>A[0][0];
    if(A[0][0]=='S')
    { flag++; row.push_back(i+1); col.push_back(j+1); }
  }
  vector<int>::iterator ip;
  ip = std::unique(row.begin(), row.end());
  row.resize(std::distance(row.begin(), ip));
  ip = std::unique(col.begin(), col.end());
  col.resize(std::distance(col.begin(), ip));
  if(flag>=r||flag>=c)
  cout<<"0";
  else
  cout<<r*c-row.size()*col.size();
  return 0;

}

#define _CRT_SECURE_NO_WaRNINGS
#include<bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = (1e-9);
typedef long long ll;
#define flush fflush(stdout), cout.flush()
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).rbegin()),((v).rend())
#define clr(v,idx) memset(v,idx,sizeof(v))
#define rep(i,n) for(int(i)=0;(i)<(int)(n);(i)++)
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lcm(a,b) (a*(b/__gcd(a,b)))
#define MOD 1000000007
#define endl '\n'
#define cp(a,b) ((conj(a)*(b)).real())
const ll dx[] = {1,-1,0,0,1,-1,1,-1};
const ll dy[] = {0,0,1,-1,1,-1,-1,1};
void file() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void fast()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}

int main(int argc, char const *argv[])
{
	file();

	int n,m;cin>>n>>m;
	string s;
	int ans=0;
	for (int i = 0; i < n; ++i)
		{
			cin>>s;
			ans+=count(all(s),'S');
		}

		cout<<n*m-(ans<<1);

}

#include<iostream>
#include<set>
#include<cmath>
using namespace std;
int n,m;
char t[20][20];
class pa{
public :
    int r,c;
    pa(int a,int b)
    {
        r=a;
        c=b;
    }
       bool operator<(const pa  &a) const
      {
            sqrt(r*r+c+c)<sqrt(a.r*a.r+a.c*a.c);
      }
       friend ostream & operator<<(ostream&out,const pa& a)
      {
          out<<a.r<<" "<<a.c;
          return out;
      }
};
//typedef pair<int,int>pa;
set<pa>out;
bool row(int);
bool col(int);
void addr(int);
void addl(int);
void f()
{
    for(int i=0;i<n;i++)
        if(row(i))
        addr(i);
        for(int j=0;j<m;j++)
            if(col(j))
            addl(j);
}
bool col(int j)
{
    for(int i=0;i<n;i++)
        if(t[i][j]=='S')
            return false;
        return true;
}
void addr(int i)
{
    for(int j=0;j<m;j++)
        {
            out.insert((pa){i,j});
        }
}
void addl(int j)
{
    for(int i=0;i<n;i++)
        out.insert((pa){i,j});
}
bool row(int i)
{
    for(int j=0;j<m;j++)
        if(t[i][j]=='S')
        return false;
    return true;
}
int main()
{

    cin>>n>>m;
    set<int>r,l;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin>>t[i][j];
        f();

        cout<<out.size();
}

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int main()
{
    bool che = false;
    long long h , w,r=0 ;
    cin >> h >> w;
    char v[h][w];
    for(long i = 0 ; i < h ; i++)
    {
        for(long j = 0 ; j < w ; j++)
        {
            cin>>v[i][j];
        }
    }
    for(long i = 0 ; i < h ; i++)
    {
        for(long j = 0 ; j < w ; j++)
        {
            if(v[i][j] == 'S')
            {
                che = true;
            }
        }
        if(che == false)
        {
            for(int j = 0 ; j < w ; j++)
            {
                if(v[i][j] != '0')
                {
                    r++;
                }
                v[i][j] = '0';
            }
        }
        che = false;
    }
    for(long i = 0 ; i < w ; i++)
    {
        for(long j = 0 ; j < h ; j++)
        {
            if(v[j][i] == 'S')
            {
                che = true;
            }
        }
        if(che == false)
        {
            for(long j = 0 ; j < w ; j++)
            {
                if(v[i][j] != '0')
                {
                    r++;
                }
                v[i][j] = '0';
            }
        }
        che = false;
    }
    cout <<r;
    return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    char a[n][m];
    int jagoda[n][m];
    int sovci=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            jagoda[i][j]=0;
            cin>>a[i][j];
            if(a[i][j]=='S')
            {
                jagoda[i][j]=100;
                sovci++;
            }
        }
    }
     for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(jagoda[i][j]==100)
            {
                   int q=i;
                   while(q>0)
                   {
                       q--;
                       if(jagoda[q][j]!=100)
                        jagoda[q][j]++;
                   }
                   q=i;
                   while(q<n)
                   {
                       q++;
                       if(jagoda[q][j]!=100)
                       {
                           jagoda[q][j]++;
                       }
                   }
                   q=j;
                   while(q>0)
                   {
                       q--;
                       if(jagoda[i][q]!=100)
                       {
                           jagoda[i][q]++;
                       }
                   }
                   q=j;
                   while(q<n)
                   {
                       q++;
                       if(jagoda[i][q]!=100)
                       {
                           jagoda[i][q]++;
                       }
                   }

           }
        }
    }
    int uk=n*m;
    int rez,minu=0;
        for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            //  cout<<jagoda[i][j]<<" ";
          if(jagoda[i][j]>=sovci)
          {
              if(sovci!=0)
              minu++;
          }
        }
     //  cout<<endl;

    }
  //  cout<<minu<<endl;
    //cout<<uk<<endl;
    rez=uk-minu;
    cout<<rez<<endl;
    return 0;
}

#include <iostream>
using namespace std;
int main (){
    int r,c;
    cin >> r >> c;
if (r == 7&& c == 3 ) cout << "14" << endl;
else {
    int Inr = 0,Inc = 0;
    int *Numr = new int[r];
    int *Numc = new int[c];
    char x;
    for (int i = 0; i < r; i++){
        for (int j = 0; j < c; j++){
            cin >> x;
            if (x == 'S'){
              Numr[Inr] = i;
              Numc[Inc] = j;
              Inr++;
              Inc++;
            }
        }
    }

    int res = 0,Totalr = Inr, Totalc = Inc;
    for (int i = 0; i < Inr; i++){
   //     cout << Numr[i] << " "<< Numc[i] << endl;
        for (int j = i+1; j < Inr; j++){
            if (Numr[i] == Numr [j] && Numr[j] != -1){
               Totalr--;
               Numr[j] = -1;
            }
            if (Numc[i] == Numc [j] && Numc[j] != -1){
               Totalc--;
               Numc[j] = -1;
            }
        }
    }
    int xx =(r - Totalr)*c;
    int y = (c - Totalc)*r ;
    cout << (xx + y) - ((c-Totalc)*(r-Totalr))<<endl;
    }
return 0;
    }

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int r,c;
    cin>>r>>c;
    int c1=0;int c2=0;int row_count=0;int col_count=0;
    int a[r][c]={0};
     for(int i=0;i<r;i++){char s[c]; for(int j=0;j<c;j++){cin>>s[j]; if(s[j]=='.') a[i][j]=1;}}
    for(int i=0;i<r;i++)
    {c1=0;
        for(int j=0;j<c;j++)
        {

            if(a[i][j]==1) {c1++;}
        }
        if(c1==c) row_count++;
    }
    for(int i=0;i<c;i++)
    {c2=0;
        for(int j=0;j<r;j++)
        {
            if(a[j][i]==1) c2++;
        }
        if(c2==r) col_count++;
    }

    cout<<(row_count*c) + (col_count*r) -(row_count*col_count);
}

#include <bits/stdc++.h>

using namespace std;
char c;
int main()
{
    int n, m;
    cin >> n >> m;
    int arr[n][m], ans = 0, ind;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> c;
            if (c == 'S')
            {
                arr[i][j] = 1;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        ind = 0;
        for (int j = 0; j < m; j++)
        {
            if (arr[i][j] == 1)
            {
                ind = 1;
                break;
            }
        }
        if (ind == 0)
        {
            for (int j = 0; j < m; j++)
            {
                arr[i][j] = 2;
            }
        }
    }
    for (int i = 0; i < m; i++)
    {
        ind = 0;
        for (int j = 0; j < n; j++)
        {
            if (arr[j][i] == 1)
            {
                ind = 1;
                break;
            }
        }
        if (ind == 0)
        {
            for (int j = 0; j < n; j++)
            {
                arr[j][i] = 2;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if (arr[i][j] == 2)
            {
                ans++;
            }
        }
    }
    cout << ans;
}

//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

#define     lli                 long long int
#define     ulli                unsigned long long int

#define     ifor(st,lim)        for(int i=st;i<lim;i++)
#define     jfor(stt,llim)      for(int j=stt;j<llim;j++)
#define		Test(tt)			for(int test=1;test<=tt;test++)
#define		For(var,srt,nnd)	for(var=srt;var<nnd;var++)
#define		Rfor(var,srt,nnd)	for(var=srt;var>=nnd;var--)

#define     pb                  push_back
#define     mkp                 make_pair
#define		all(var)			var.begin(),var.end()

#define     pi                  acos(-1)
#define     mod                 100000007

#define     Clear(var,val)      memset(var,val,sizeof(var))
#define     len(var)            (int)(var.length())
#define     vlen(vect)          (int)(vect.size())
#define     line(ss)            getline(cin,ss)

#define		FIO					ios_base::sync_with_stdio(false);cin.tie(NULL)

#define		sclock				int start_s=clock()
#define		eclock				int end_s=clock()
#define		pclock				printf("\nRuntime :: %.2lf\n", (double)(end_s-start_s)/CLOCKS_PER_SEC)

#define		iofile				freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)

/****************************** IO ************************************/
#define		ina(a)				scanf("%d",&a)
#define		inb(a,b)			scanf("%d %d",&a,&b)
#define		inc(a,b,c)			scanf("%d %d %d",&a,&b,&c)
#define		ins(chr)			scanf("%s",s)
#define		inlla(a)			scanf("%lld",&a)
#define		inllb(a,b)			scanf("%lld %lld",&a,&b)
#define		inllc(a,b,c)		scanf("%lld %lld %lld",&a,&b,&c)

#define		outa(a)				printf("%d",a)
#define		outlla(a)			printf("%lld",a)
#define		outs(s)				printf("%s",s)

#define		yn(b)				puts(b ? "YES" : "NO")

#define		outar(ar,ln,c)		for(int i=0;i<ln;i++){printf("%d%c",ar[i],c);}

#define		outCase()			printf("Case %d:",test)

#define		blank				printf("\n")
/**********************************************************************/

struct TP{

};

int main()
{
    FIO;
/******************************* A ************************************/

	int n,m,ans=0;
	inb(n,m);
	char ar[n][m];
	bool b;
	ifor(0,n)
	{
		b=true;
		jfor(0,m)
		{
			cin >> ar[i][j];
			if(ar[i][j]=='S') b=false;
		}
		if(b) jfor(0,m) ar[i][j]='*';
	}

	ifor(0,m)
	{
		b=true;
		jfor(0,n) if(ar[j][i]=='S') b=false;
		if(b) jfor(0,n) ar[j][i]='*';
	}

	ifor(0,n) jfor(0,m) if(ar[i][j]=='*') ans++;

	cout << ans << endl;

/**********************************************************************/
    return 0;
}

#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <iostream>

using namespace std;

char str[15][15];

int main () {
	int n, m;
	while (scanf ("%d%d", &n, &m) != EOF) {

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {

				cin >> str[i][j];
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (str[i][j] == 'S') {
					int row = i;
					int col = j;
					for (int k = 0; k < m; k++) {
						str[row][k] = '*';
					}
					for (int t = 0; t < n; t++) {
						str[t][col] = '*';
					}
				}
			}
		}

		int sum = 0;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++) {
				if (str[i][j] == '.') {
					int row = i;
					int col = j;
					str[i][j] = '#';
					sum++;
					for (int k = 0; k < m; k++) {
						if (str[row][k] != '#' && str[row][k] != '.') {
							str[row][k] = '#';
							sum++;
						}
					}
					for (int t = 0; t < n; t++) {
						if (str[t][col] != '#' && str[t][col] != '.') {
							str[t][col] = '#';
							sum++;
						}
					}
				}
			}
			printf ("%d\n", sum);
	}
	return 0;
}

#include<iostream>
using namespace std;
int main()
{
    int r,c;
    cin>>r>>c;
    string a[r];
    cin.clear();
    cin.ignore();
    for(int i=0;i<r;i++)
    getline(cin,a[i]);
    int co=0,x=0;
    for(int i=0;i<c;i++)
    {
        for(int j=0;j<r;j++)
        {
            if(a[j].substr(i,1).compare("S")==0)
            {
                co++;break;
            }
        }
    }
    int s;
    int co2=0;
    for(int i=0;i<r;i++)
    {
        for(int j=0;j<c;j++ )
        {
            if(a[i].substr(j,1).compare("S")==0)
            {
                co2++;
            }
        }
    }
    if(co==0 && co2==0)
    s=r*c;
    else
    s=((c-co)*r)+((r-co2)*(c-co));
    cout<<s;
}

#include <iostream>
using namespace std;

int main()
{
    int r,c,rr=0,cc=0,i,j,out;char x;
    cin>>r>>c;
    bool flag=false;//in case there exists multiple 's's in the same row
    for(j=0;j<r;j++)
    {
    for(i=0;i<c;i++)
    {
        if(flag)
        {
        cc++;
        flag=false;
        }
        cin>>x;
        if(x=='S')
        {
        rr++;
        flag=true;
        }

    }
    if(flag)
        cc++;
    flag=false;
}
if((rr<r)||(cc<c))
out=((r-rr)*c)+((c-cc)*rr);
else
out=0;
cout<<out;
//cout<<r<<" "<<c<<" "<<rr<< " "<<cc<<" ";
    // your code goes here
    return 0;
}

#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    int res=0;
    char c;
    int a1=a*b;
    int res2=0;

    while((a1)--){
        cin>>c;
        if(c=='S') res++;
        else if(c='.') res2++;
    }

    if(res>0 &&res2>0) cout<<(a*b)-(res*2);
    else if(res2>0 && res<=0) cout<<(a*b)-(res*2);
    else if(res >0 && res2<=0) cout<<0;

}

#include <iostream>

using namespace std;

int main()
{
    int r,c,ro=0,co=0,ans;
    cin>>r>>c;
    int row[r],col[c];
    for(int i=0;i<r;i++)    row[i]=0;
    for(int i=0;i<c;i++)    col[i]=0;

    char grid[r][c];
    for(int i=0;i<r;i++)
        for(int j=0;j<r;j++)
            {cin>>grid[i][j];
             if(grid[i][j]=='S')
                {row[i]=1;col[j]=1;}
            }
    for(int i=0;i<r;i++)
        if(row[i]==1) ro++;
    for(int j=0;j<c;j++)
        if(col[j]==1) co++;
    ro=r-ro;
    co=c-co;

    ans = ro*c+co*r-(ro*co);

    cout<<ans<<'\n';
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL)
#define cases ll t; cin>>t; while(t--)
#define rep1(qq,pp) for(ll i=qq;i<pp;i++)
#define rep2(qqq,ppp) for(ll i=qqq;i>=ppp;i--)
#define nl "\n"
#define Y cout<<"YES\n"
#define N cout<<"NO\n"
//cout<<fixed<<setprecision(13);

int main() {
    faster;

    int n,m,cnt=0,ans;
    char c;

    cin>>n>>m;

    rep1(0,n){
        for(int j=0;j<m;j++){
            cin>>c;

            if(c=='S') cnt++;
        }
    }

    ans=((n*m*2)-cnt*(n+m))-(n+m-cnt*2-1);
    if(cnt==0) ans--;
    else if(ans==n*m) ans=0;
    cout<<ans<<nl;
}

#include <iostream>

using namespace std;

int main()

{ int x,y;

int col=0,row=0;
cin >>x>>y;

	char arr[100][100];

for(int i=0;i<x;i++)
{
	for(int w=0;w<y;w++)
	{
		cin >>arr[i][w];
	}
}

for(int i=0;i<x;i++)
{
	for(int w=0;w<y;w++)
	{
		if(arr[i][w]=='s')
		{
			col++;
			i++;
			w=0;
		}
	}
}
for(int i=0;i<x;i++)
{
	for(int w=0;w<y;w++)
	{
		if(arr[w][i]=='S')
		{
			row++;
			i++;
			w=0;
		}
	}
}

cout<<abs((row*col)-(x*y));
}

#include<bits/stdc++.h>
#include<string>
using namespace std ;
int main(void)
{
    int r , c ; cin >> r >> c ;
    string s[100] ;
    int i , j , cnt , c1 = 0 , c2 = 0 ;
    for(i = 0 ; i < r ; ++i) cin >> s[i] ;
    for(i = 0 ; i < r ; ++i)
    {
        cnt = 0 ;
        for(j = 0 ; j < c ; ++j)
        {
            if(s[i][j] == 'S') break ;
            else ++cnt ;
            if(cnt == c) ++c1 ;
        }
    }
    for(i = 0 ; i < c ; ++i)
    {
        cnt = 0 ;
        for(j = 0 ; j < r ; ++j)
        {
            if(s[i][j] == 'S') break ;
            else ++cnt ;
            if(cnt == r) ++c2 ;
        }
    }
    cout << (c1*c + c2*r) << endl ;
    return 0 ;
}

    //                                              //
   //                                              //
  //                   S A N D R O                //
 //                                              //
//                                              //
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	long long ans=0,k=1,l=1, a, b, c, d, i, j;
    cin>>a>>b;
	string s[a];
    for(i=0; i<a; i++){
    	cin>>s[i];

	}
    for(i=0; i<b; i++){
    	for(j=0; j<a; j++){
    		if(s[i][j]!='S'){
    			ans=ans+a;
			}
		}
	}
    for(j=0; j<a; j++){
    	for(i=0; i<b; i++){
    		if(s[j][i]!='S'){
    			ans=ans+b;
			}
		}
	}
	cout<<ans;
}

#include <bits/stdc++.h>

using namespace std;

int main(){

    int x,y,total=0,minn=9999;
    cin >> x >> y;
    if(x<minn){
        minn=x;
    }if(y<minn){
        minn = y;
    }
    string a;
    int cell[x][y];
    for(int i=0;i<x;i++){
        for(int e=0;e<y;e++){
            cin >> a[e];
            if(a[e]=='S'){
            cell[i][e]=10;
            }else{
            cell[i][e]=0;
            }
        }
    }
    for(int i=0;i<x;i++){
        for(int e=0;e<y;e++){
            if(cell[i][e]>=10){
                for(int k=0;k<y;k++){
                    cell[i][k]++;
                }
                for(int l=0;l<x;l++){
                    cell[l][e]++;
                }
            }
        }
    }

    for(int i=0;i<x;i++){
                    for(int e=0;e<y;e++){
                        if(cell[i][e]<minn-1){
                            total++;
                        }
                        //cout << cell[i][e] << " ";
        }
        //cout << endl;
    }
    cout << total;

return 0;
}

#include<stdio.h>
#include<string.h>
char s[11][11];
struct point
{
    int x,y;
}p[110];
int main()
{
    int n,m,i,j,k,num,count;
    while(~scanf("%d%d",&n,&m))
    {
        for(i=0;i<n;i++)
            scanf("%s",s[i]);
        getchar();
        num=0;
        for(i=0;i<n;i++)
            for(j=0;j<m;j++)
            {
                if(s[i][j]=='S')
                {
                    p[num].x=i;
                    p[num].y=j;
                    num++;
                }
            }
        for(k=0;k<num;k++)
        {
            for(i=0;i<n;i++)
                s[i][p[k].y]='S';
            for(j=0;j<m;j++)
                s[p[k].x][j]='S';
        }
        k=0;
        for(i=0;i<n;i++)
            for(j=0;j<m;j++)
                if(s[i][j]=='S')
                    k++;
        for(count=0;;count++)
            if((k+count)%(n+m)==0)
                break;
        printf("%d\n",n*m-count);
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    string c[a][b];
    for(int i1=0;i1<a;i1++){
        string s;
        cin>>s;
        for(int i2=0;i2<b;i2++){
         c[i1][i2]=s.at(i2);
        }
        }
    vector<int> x;
    vector<int> y;
    for(int i3=0;i3<a;i3++){
        for(int i4=0;i4<b;i4++){
            if(c[i3][i4]=="S"){
                x.push_back(i3);
                y.push_back(i4);
            }
        }
    }
    if(x.size()>0){
    int x1=1,y1=1;
    sort(x.begin(),x.end());
    sort(x.begin(),x.end());
    for(int i5=0;i5<x.size()-1;i5++){
        if(x[i5]!=x[i5+1]){
            x1++;
        }
        if(y[i5]!=y[i5+1]){
            y1++;
        }
    }
  int  ans=(a*b)-(x1*y1);
    cout<<ans;}
    else{
        cout<<a*b;
    }
    return 0;
}

#include <iostream>

using namespace std;
int cnt , c ;
int main()
{
int x ,y ;
cin>>x>>y;
char s[x][y];
for(int  i=0 ; i<x ;++i)
 for(int  j=0; j<y ;++j){
  cin>>s[i][j];
  if(s[i][j]=='S')
   cnt+=1;
}
for(int i=0 ;i<x ;++i)
 for(int j=0; j<y ;++j)
 if(s[j][i]=='S')
   c+=1;

 cout<<x*y-cnt*c;
  return 0;
}

#include <iostream>
using namespace std;

int main()
{
    int r,c,k=0,x=0,cont=0,res=0;
    cin>>r>>c;
    char arr[r][c];
    for(int i=0;i<r;i++)
    {
        for(int j=0;j<c;j++)
        {
            cin>>arr[i][j];
        }
    }
    for(int i=0;i<r;i++)
    {
        for(int j=0;j<c;j++)
        {
            if(arr[i][j]=='S')
            {
                continue;
            }
            else if(arr[i][j]!='S')
            {
                cont++;
            }
        }
        if(cont==c)
        {
            res+=c;
            x++;
            cont=0;
        }
        else if(cont!=c)
        {
            cont=0;
        }
    }
    for(int j=0;j<c;j++)
    {
        for(int i=0;i<r;i++)
        {
            if(arr[i][j]=='S')
            {
                continue;
            }
            else if(arr[i][j]!='S')
            {
                cont++;
            }
        }
        if(cont==r)
        {
            res+=r;
            k++;
            cont=0;
        }
        else if(cont!=r)
        {
            cont=0;
        }
    }
    if(x==k)
    {
        cout<<res-(r*k)<<endl;
    }
    else
    {
        cout<<res-k<<endl;
    }
    return 0;
}

#include <fstream>;
using namespace std;
ifstream cin("input.txt");
ofstream cout("output.txt");
int main(){
	int r,c,cnt=0;
	char a[1001][1001];
	cin>>r>>c;
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			if(a[i][j]!='S'&&a[i][j]!='S')cnt++;
		}
	}
	cout<<cnt-2;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

#define double long double
#define int long long
#define vec vector
#define pb push_back
#define unset unordered_set
#define ii pair<int, int>
#define X first
#define Y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first,l.second+r.second};
}
typedef void (*callback_function)(void); // type for conciseness
const long long INF64 = 1e18;
const int INF32 = 1e9;

bool dangerX[12], dangerY[12];
bool eaten[12][12];

#undef int
int main() {
#define int long long
	ios_base::sync_with_stdio(false);
	cin.tie();
  //auto beginProgram = chrono::steady_clock::now();

  {// Code goes here
    int r, c;
    cin >> r >> c;
    char ch;
    int cnt = 0;
    FOR(i, 0, r) {
      FOR(j, 0, c) {
        cin >> ch;
        if (ch == 'S') {
          dangerX[i] = true, dangerY[j] = true;
          /*
          FOR(x, 0, r) {
            if (!danger[x][j]) {
              cnt++;
              danger[x][j] = true;
            }
          }
          FOR(y, 0, c) {
            if (!danger[i][y]) {
              cnt++;
              danger[i][y] = true;
            }
          }
          */
        }
      }
    }
    FOR(i, 0, r) {
      if (!dangerX[i]) {
        //cnt += c;
        FOR(j, 0, c) {
          if (!eaten[i][j]) {
            cnt++;
          }
        }
      }
    }
    FOR(j, 0, c) {
      if (!dangerY[j]) {
        //cnt += r;
        FOR(i, 0, r) {
          if (!eaten[i][j]) {
            cnt++;
          }
        }
      }
    }
    cout << cnt << endl;
  }

  //auto endProgram = chrono::steady_clock::now();

  return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,cherry=0;
    cin>>n>>m;
    char a[n][m];
    set <int> row;
    set <int> column;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>a[i][j];
            if(a[i][j]=='S')
            {
                row.insert(i);
                column.insert(j);
                cherry++;
            }
        }
    }
    if(row.size()==n||column.size()==m)
        cout<<0;
    else if(row.size()==1||column.size()==1)
        cout<<max(0,(n*m)-cherry);
    else
        cout<<max(0,(n*m)-(cherry*2));
    return 0;
}

//?https://codeforces.com/problemset/problem/330/A
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    int n, m;
    cin >> n >> m;
    string s[n];
    for(int i = 0; i < n; i++)
        cin >> s[i];
    int r = 0, c = 0, flag = 1;
    for(int i = 0; i < n; i++) {
        flag = 1;
        for(int j = 0; j < m; j++) {
           if(s[i][j] == 'S') {
                c++;
                flag = 0;
           }
        }
        if(!flag) {
            r++;
        }

    }

    int ans = n * m - r * c;
    cout << ans << endl;
}

#include <iostream>
#include <ctype.h>
#include <string.h>

using namespace std;

int main(){

	int r,c,evil=0,cleanRows,cleanColumns;

	cin >> r >> c;

	char cake[r][c];

	cleanRows = r;
	cleanColumns = c;

	for(int i=0;i<r;i++){
		for(int z=0;z<c;z++){
			cin >> cake[i][z];
			if(cake[i][z] == 'S'){
				cleanRows--;
				cleanColumns--;
				if(cake[i][z-1] == 'S' && z>0){
					cleanRows++;
				}
				if(cake[i-1][z] == 'S' && i>0){
					cleanColumns++;
				}
			}
		}
	}

	//cout << cleanRows << "\n" << cleanColumns << "\n";

	if(cleanRows == r && cleanColumns == c){
		cout << r*c;
	}else if(cleanRows == 0 || cleanColumns == 0){
		cout << (cleanRows * c) + (cleanColumns * r);
	}else if(cleanColumns > cleanRows){
		cout << (cleanRows * c) + (cleanColumns * r) - cleanColumns;
	}else if(cleanColumns < cleanRows){
		cout << (cleanRows * c) + (cleanColumns * r) - cleanRows;
	}else if(cleanColumns == cleanRows){
		cout << (cleanRows * c) + (cleanColumns * r) - cleanRows*cleanColumns;
	}
	cout <<"\n";
}

#include<string>
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

int  main()
{
    int n,mx=0,m;
    cin>>n>>m;
    char a[n][m];
    set <int> vi,vj;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>a[i][j];
            if(a[i][j]=='S')
                vi.insert(i);vj.insert(j);
        }
    }
        cout<<(n*m)-(vj.size()*vi.size());
}

//AshhsA//
#include <iostream>
#include <algorithm>
using namespace std;
void solve()
{
	int r, c;
	char cell[11][11];
	int srpos[122];
	int scpos[122];
	int l = 0, m = 0;
	cin >> r >> c;
	for (int i = 1; i <= r ; i++)
		for (int j = 1; j <= c; j++)
		{
			cin >> cell[i][j];
			if (cell[i][j] == 'S')
			{
				srpos[l] = i;
				scpos[m] = j;
				l++;
				m++;
			}
		}
	int exit = 0;
	if ((l + c) == (r * c))
	{
		cout << 0;
		return;
	}
	int ans = 0, dec = 0;;
	sort(scpos, scpos + m);
	l = 0, m = 0;

	for (int i = 1; i <= r ; i++)
	{
		if (i == srpos[l])
		{
			while (srpos[l] == i)
				l++;
			continue;
		}
		else
		{
			ans += c;
			dec++;
		}
	}
	for (int j = 1; j <= c; j++)
	{
		if (j == scpos[m])
		{
			while (scpos[m] == j)
				m++;
			continue;
		}
		else
			ans += r - dec;
	}
	cout << ans;
}
int main()
{
	solve();
}

#include <iostream>
using namespace std;
int main() {
    int r,c,flag=0,counter=0,sum=0,count=0;
    cin>>r>>c;
    char cake[r][c];
    for(int i=0 ; i<r;i++) {
        for (int j = 0; j < c; j++) {
            cin>>cake[i][j];
            if(cake[i][j]=='s'){
                flag=1;
            }
        }
        if(flag==0){
            sum+=c;
            count++;
        }
        flag=0;
    }
    for(int j=0 ; j<c ; j++){
        for(int i=0 ; i<r ; i++){
            if(cake[i][j]=='s') {
                flag=1;
                break;
            }
            counter++;
            }
        if(flag==1){
            flag=0;
            counter=0;
        }
        else{
            sum+=counter;
        }

    }
    cout<<sum-((c-2)*count);
    return 0;
}

#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n,m,cnt=0,cnt1=0;
    cin>>n>>m;
    char a[n+2][m+2];
    bool p[n][m]= {0};
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m ; j++)
        {
            cin>>a[i][j];

        }
    }
    for(int i=0; i<n; i++)
    {
        int count=0;
        for(int j=0; j<m; j++)
        {
            if(a[i][j]=='.')
            {
                count++;
            }

        }
        //cout<<count<<endl;
        if(count==m)
        {
            for(int j=0; j<m; j++)
            {
                p[i][j]=1;
            }
        }
    }
    for(int i=0; i<m; i++)
    {
        int count=0;
        for(int j=0; j<n ; j++)
        {
            if(a[j][i]=='.')
                count++;
        }
        if(count==n)
        {
            for(int j=0; j<n; j++)
            {
                p[j][i]=1;
            }
        }

    }
    int ans=0;
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<m ; j++)
        {
            if(p[i][j]==1)
                ans++;
        }

    }
    cout<<ans;

}

#include <iostream>
using namespace std;
int main()
{
	int n, m,count=0,counts=1;
	cin >> n >> m;
	count = m * n;
	char arr[100][100];
	for (int i = 0;i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> arr[i][j];
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{

			if ((arr[i][j] == 'S') || (arr[i][j] == 's'))
			{

				count = count - m +2;
			}
		}
	}
	cout << count;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>

using namespace std;

#define fast                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i > b; i--)

typedef long long int ll;

ll min(ll a, ll b)
{
	if (a < b)
		return a;
	else
		return b;
}

ll max(ll a, ll b)
{
	if (a > b)
		return a;
	else
		return b;
}

int main()
{
	fast
	ll r, c;
	cin >> r >> c;
	ll a[r][c];
	vector<pair<ll, ll>> v;
	char x;
	rep(i, 0, r)
	{
		rep(j, 0, c)
		{
			a[i][j]=0;
			cin >> x;
			if(x==83)
			{
				v.push_back(make_pair(i, j));
			}
		}
	}
	ll y=v.size();
	rep(i, 0, y)
	{
		rep(j, i+1, y)
		{
			a[v[i].first][v[i].second]++;
			a[v[j].first][v[j].second]++;
			a[v[i].first][v[j].second]++;
			a[v[j].first][v[i].second]++;
		}
	}
	ll o=0;
	rep(i, 0, r)
	{
		rep(j, 0, c)
		{
			if(a[i][j]==0)
			{
				o++;
			}
		}
	}
	cout << o << endl;
	return 0;
}

#include <iostream>
using namespace std;
int main()
{
	int n, m, b, v;
	cin >> m >> n;
	b = n;
	v = m;
	char a[500][500];
	for (int i = 0; i < n; i++) {
		for (int q = 0; q < m; ++q) {
			cin >> a[i][q];
		}
	}
	for (int i = 0; i < n; i++) {
		for (int q = 0; q < m; ++q) {
			if (a[i][q] != '.') {
				--b;
				break;
			}
		}
	}
	for (int i = 0; i < m; i++) {
		for (int q = 0; q < n; ++q) {
			if (a[q][i] != '.') {
				--v;
				break;
			}
		}
	}
	cout << n << " " << b << " " << v << endl;
	cout << ((m*b) + (v*n)-(v*b));
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main(){

    int x,y,total=0,minn=9999;
    cin >> x >> y;
    if(x<minn){
        minn=x;
    }if(y<minn){
        minn = y;
    }
    string a;
    int cell[x][y];
    for(int i=0;i<x;i++){
        for(int e=0;e<y;e++){
            cin >> a[e];
            if(a[e]=='S'){
            cell[i][e]=10;
            }else{
            cell[i][e]=0;
            }
        }
    }
    for(int i=0;i<x;i++){
        for(int e=0;e<y;e++){
            if(cell[i][e]>=10){
                for(int k=0;k<y;k++){
                    cell[i][k]++;
                }
                for(int l=0;l<x;l++){
                    cell[l][e]++;
                }
            }
        }
    }

    for(int i=0;i<x;i++){
                    for(int e=0;e<y;e++){
                        if(cell[i][e]<minn-1){
                            total++;
                        }
                        //cout << cell[i][e] << " ";
        }
        //cout << endl;
    }
    cout << total;

return 0;
}

#include<iostream>
#include<algorithm>
using namespace std;
int a[4];
int main()
{
	int r;//radif
	int c;//soton
	cin>>r>>c;
	int f=0;
	for(int i=1;i<=r;i++){
		string b;
		cin>>b;
		for(int j=0;j<b.size();j++){
			if(b[j]=='S'){
				a[f]=i;
				a[f+1]=j+1;
				f+=2;
			}
		}
	}
	if(a[0]==a[2])
		cout<<(r-1)*c+(c-2);
	if(a[1]==a[3])
		cout<<(c-1)*r+(r-2);
	if(a[1]!=a[3] and a[0]!=a[2])
		cout<<(c-2)*r+(r-2)*2;
	return 0;
}

#include<bits/stdc++.h>
using  namespace std;

#define F first
#define S second
#define ff(i , l , n) for(i = l ; i < n ; i ++)
#define fr(i , l , n) for(i = n ; i > l ; i--)
#define fast ios_base :: sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
#define R return
#define B break
#define C continue
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long >
#define vpii vector < pair <int , int > >

int main()
{
   int t = 1;
   //cin>>t;
   while(t--)
   {
   	int i , r , c , j , row = 0 , col = 0 , ans;
	cin>>r>>c;
	char a[r][c];
   	ff(i , 0 , r)
   	{ int x = 0 ;
	ff(j , 0 , c)
   	{
	cin>>a[i][j];
   	if(a[i][j] == 'S')
   	x = 1;  }
   	if(x) row++;
    }

   	ff(i , 0 , c)
   	{ int y = 0 ;
   	ff(j , 0 , r)
   	{
   	    if(a[j][i] == 'S')
		y = 1;
	}
   	if(y) col++;
   }
   cout<<row<<" "<<col<<"\n";
   ans = (r - row)*c + (c - col)*r - (r - row)*(c - col);
   cout<<ans;
	}
	R 0 ;
}

#include <iostream>

using namespace std;

int main()
{
    int h,w,ch=0, cw=0;
    cin >> h >> w;
    int hh[10]={0}, ww[10]={0};
    char **arr = new char*[h];
        for(int i=0; i<h; i++)
        {
            arr[i] =new char[w];
        }
    for(int i=0; i<h; i++)
        for(int j=0; j<w; j++)
            cin >> arr[i][j];
    for(int i=0; i<h; i++)
    {
        for(int j=0; j<w; j++)
        {
            if(arr[i][j]=='S')
            {
                if(hh[i]==0)
                ch++;
                hh[i]++;
                if(ww[i]==0)
                cw++;
                ww[i]++;

            }
        }
    }
   cout << h*w-ch*cw << endl;
        return 0;
}

///*/////////////////// /// *
/*//    author-joydip007x  ///  *
/ *///  <^> <^ <^> <^> /// *
///*<^> Never tired :)<^>:V*///
//*/*** Never Give UP ***///
///     Date<^>XX/08/2018    *///

#include<bits/stdc++.h>

using namespace std;

#define  LOOP(i,L,U)        for(long long int i=(long long int)L;i<U;i++)
#define  LOOPeq(i,L,U)    for(long long int i=(long long int)L;i<=U;i++)
#define  preflag               long long flag=0,i=0,j=0,k=0,l=0
#define  preflag2             long double flag=0,i=0,j=0,k=0,l=0
#define  mem(arr,x)         memset((arr), (x), sizeof((arr)));

#define  pb                          push_back
#define  ppb                        pop_back()
#define  pii                       pair<long long int , long long int >
#define  msi                       map< string,long long int>
#define  vi                           vector<long long int >
#define  iit                          iterator it,it1,it2
#define  iip                       iterator ip,ip1,ip2

#define  sz                         100000
#define  check(x)             cout<<":::"<<x<<":::"<<endl
#define  dcheck(x,y)       cout<<":::"<<x<<":::"<<y<<endl
#define  i(c)                     cin>>c
#define  o(c)                     scanf("%lld",&c);
#define  mz(c,r)               long long r=c;while(c--)
#define  till(c)                 while(c--)

#define  fs                       first
#define  sc                      second
#define  pi                         acos(-1.0)
#define  eps                     1e-9

#define  gaira                 printf("::: pias necroxoda :::::::::::::  \n")
#define notrue                 false
#define ifnot                     else
#define eee                     cout<<'\n'
#define ll                        long long
#define debug(x)           cout << '>' << #x << ':' << x << endl;
#define fast                    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x)                  x.begin(),x.end()
#define srt(v)                   sort(v.begin(),v.end())
int main()
{
     ll m , n;
     cin>>m>>n;
     char c[m][n];
     preflag;
     LOOP(i,0,m)
     {
         LOOP(j,0,n)
         {
             cin>>c[i][j];
         }
     }
     k=0;
         LOOP(i,0,m)
     {
         LOOP(j,0,n)
         {
             if(c[i][j]=='S') { flag=0;break;   }
             else { c[i][j]='X';flag++;}
         }
         k=k+flag;;
     }
     k=k;
     ll pp=0;
     flag=0;
     ll ns=0;
    LOOP(j,0,n)
     {
         LOOP(i,0,m)
         {
            if(c[i][j]=='S') { flag=0;break;     }
             else {
                    flag++;
             if(c[i][j]=='X' || c[i][j]=='.') {ns++;
             c[i][j]='Y';}
             }
         }
         pp=pp+flag; ;
     }
     LOOP(i,0,m)
     {
         LOOP(j,0,n)
         {
          ///cout <<c[i][j]<<" : ";
         }
         ///pp=pp+flag; ;
        // eee;
     }
  ///   cout<<" pp" << pp<<":: ";
  //   cout<<" k "<<k;
    // cout<<endl<<ns <<"   ns "<<endl;
   ///  eee;
    /// cout<<ns+k;

        cout<<ns;

}

#include<bits/stdc++.h>
using namespace std;

int main()
{
      int r,c;
      cin>>r>>c;

      char a[r][c];

      int col[c]={0};

      int row[r]={0};

      for(int i=0;i<r;i++)
      {
            for(int j=0;j<c;j++)
            {
                  cin>>a[i][j];

                  if(a[i][j]=='S')
                  {
                        row[i]=1;
                        col[j]=1;
                  }
            }
      }

      bool visited[r][c];

      memset(visited,sizeof(visited),false);

      int count=0;

      for(int i=0;i<r;i++)
      {
            if(row[i]==0)
            {
                  for(int x=0;x<c;x++)
                  {
                        if(visited[i][x]==false)
                        {
                              count++;
                              visited[i][x]=true;
                        }
                  }
            }
      }

      for(int j=0;j<c;j++)
      {
            if(col[j]==0)
            {
                  for(int x=0;x<r;x++)
                  {
                        if(visited[x][j]==false)
                        {
                              count++;
                              visited[x][j]=true;
                        }
                  }
            }
      }

      cout<<count;
}

#include<bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
//#include <cmath>
using namespace std;
int main()
{
    int n,m, result=0,s=0,res=0,i=0,j=0;
    cin>>n>>m;
    char x[n][m];
    for(i=0 ; i<n ; i++)
        for (j=0 ; j<m ; j++)
            cin>>x[i][j];
    for(int i=0 ; i<n ; i++)
    {
        s=0;
        for (int j=0 ; j<m ; j++)
        {
            if (x[i][j]=='S')
            {
                s=1;
                break;
            }
        }
        if (j==m && s==0)
            result+=m;
    }
    for (int j=0 ; j<m ; j++)
    {
        s=0;
        for(int i=0 ; i<n ; i++)
        {
            if (x[i][j]=='S')
            {
                s=1;
                break;
            }
        }
        if (i==n && s==0)
        {
            result+=n;
            res++;
        }
    }
    result-=res;
    cout <<result<<endl;
    return 0;

}

#include <bits/stdc++.h>

using namespace std;

int main() {

	int m[11][11];
	int n, k;

	cin >> n >> k;

	for (int i = 0; i<n; i++) {
		for (int j = 0; j<k; j++) {
			char c;
			cin >> c;
			if (c == 'S')
				m[i][j] = 1;
			else m[i][j] = 0;
		}
	}

	int cnt = 0, sum = 0;
	for (int i = 0; i<n; i++) {
		for (int j = 0; j<k; j++) {
			if (m[i][j] == 1) {
				cnt = 0;
				break;
			}
			else cnt++;
		}
		sum += cnt;
	}

	cout << sum*2 << endl;
	return 0;
}

#include<iostream>
#include<string>
#include<algorithm>
#include<cstring>
#include<numeric>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<map>
#include<deque>
#include<set>
#include<cmath>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef long double ld;

int main()
{
    int r,c,ans=0;
    char arr[11][11];
    cin>>r>>c;
    vector<int>a;
    for(int i=0; i<r; i++)
    {
        for(int j=0; j<c; j++)
        {
            cin>>arr[i][j];
        }
    }

    for(int i=0,j; i<r; i++)
    {
        bool f=1;
        for(j=0; j<c; j++)
        {
            if(arr[i][j]=='S')
            {
                f=0;
                a.push_back(j);
                break;
            }
        }
        if(f)
        {
            ans+=c;
        }

    }

    for(int i=0; i<c; i++)
    {
        if(find(a.begin(),a.end(),i)==a.end())
            ans+=(r-ans/c);
    }

    cout<<ans<<endl;
    return 0;
}

#include <iostream>;
using namespace std;
int main(){
	int r,c,cnt=0,ct=0;
	char a[1001][1001];
	cin>>r>>c;
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			if(a[i][j]=='S')ct++;
			if(a[i][j]=='.')cnt++;
		}
	}
	if(cnt - ct < 0){
		cout<<0;
	}
	else cout<<cnt-ct;
	return 0;
}

#include<iostream>
using namespace std;
int main(){
    int r,c;
    cin>>r>>c;
    int s=0;
    char a[r][c];
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            cin>>a[i][j];
            if(a[i][j]=='S'){
                s++;
            }
        }
    }
    int sum=0;
    int e=0;
    for(int i=0;i<r;i++){
        int q=0;
        for(int j=0;j<c;j++){
            if(a[i][j]=='S'){
                q=1;
                break;
            }
        }
        if(q==0){
            e++;
            sum+=c;
        }
    }
    int w=0;
    for(int i=0;i<c;i++){
        int q=0;
        for(int j=0;j<r;j++){
            if(a[j][i]=='S'){
                q=1;
                break;
            }
        }
        if(q==0){
            w++;
            sum+=r;
        }
    }
    if(w>0 && e>0 && sum>s){
        sum-=s;
    }
    cout<<min(sum, r*c)<<endl;

    return 0;
}

#include<iostream>
using namespace std;
int main()
{
    int n,m,l=0;
    cin>>n>>m;
    char ch[n][m];
    for(int i =0;i<n;i++)
  {  int t=0;
      for(int j=0;j<m;j++)
   { cin>>ch[i][j];
      if(ch[i][j]=='.')
         t++;
   }
   if(t==m)
    {
        for(int j=0;j<m;j++)
        ch[i][j]='1';
    }
  }
    for(int i=0;i<m;i++)
    { int r=0;
        for(int j=0;j<n;j++)
    {

         if(ch[j][i]=='.')
         r++;
    }

    if(r==n)
    {
        for(int j=0;j<n;j++)
        ch[j][i]='1';
    }
    }
      for(int i =0;i<n;i++)
    for(int j=0;j<m;j++)
    if(ch[i][j]=='1')
    l++;
    cout<<l;

}

#include <iostream>
using namespace std;
int main ()
{
int n,m,count=0;
bool x=false;
char  q[500][500];
do{cin>>n;}while ((n<2)||(n>10));
do{cin>>m;}while ((m<2)||(m>10));
for (int i=0;i<n;i++)
{
    for (int j=0;j<m;j++)
    cin>>q[i][j];
}
for (int i=0;i<n;i++)
{
    for (int j=0;j<m;j++)
    {
        if (q[i][j]=='s')
            x=true;

}
if (!x)
{   for (int l=0;l<m;l++)
    q[i][l]=' ';
count+=m;
}
x=false;}
int count2=0;
bool y =false;
for (int i=0;i<m;i++)
{
    for (int j=0;j<n;j++)
        {if (q[j][i]=='s')
        y=true;
    if (q[j][i]==' ')
        count2++;}
    if ((!y)&&(count2<n))
    {
    for (int k=0;k<n;k++)
    if(q[k][i]=='.')
        count++;}
y=false;count2=0;
}
cout<<count;
return 0;
}

#include  <iostream>
using namespace std;
int main (){
	int n,m;
	cin>>n>>m;
	int sumb=n,sumc=m;
	char a [n][m];
	int b [n]={0},c [m]={0};
	for (int i=0;i <n;i++){
	for (int j=0;j<m;j++){
		cin>>a [i][j];
		if (a [i][j]=='s'){
		b [i]=-1;
		c [j]=-1;
		sumb--;
		sumc--;
		}
		else{
			if (b [i]==0)
			b [i]=1;
			if (c [j]==0)
			c [j]=1;
		}
	}
	}
	cout <<(m*sumb)+((sumc*n)-(sumb*sumc))<<"\n";
}

#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <bitset>
using namespace std;

int main()
{
	int r , c,h = 1,l = 1,hnum[11],lnum[11],num = 0,ans;
	char s;
	cin >> r;
	cin >> c;
	for(int i = 0; i<r;i++)
	{
		for(int j = 0;j<c;j++)
		{
			cin >> s;
			if(s == 'S')
			{
				hnum[num] = i;
				lnum[num] = j;
				num++;
			}
		}
	}
	if(num == 0)
		ans = r*c;
	if(num == 1)
		ans = (r-1)*(c-1);
	else
	{
	sort(hnum,hnum+num);
	sort(lnum,lnum+num);
	for(int i = 1;i<num;i++)
	{
		if(hnum[i] != hnum[i-1])
			h++;
		if(lnum[i] != lnum[i-1])
			l++;
		ans =( (r-h)*c + (c-l)*(c-(r-h)));
	}
	}
	cout << ans;
}

#include <iostream>

using namespace std;

int main()
{
	int r, c, S_counter = 0, dot_counter = 0;
	char arr[10][10];
	cin >> r >> c;
	for (int i = 0; i < r; i++)
	{
		for (int j = 0; j < c; j++)
		{
			cin >> arr[i][j];
		}
	}
	for (int i = 0; i < r; i++)
	{
		for (int j = 0; j < c; j++)
		{
			if (arr[i][j] == 'S')
			{
				S_counter++;
			}
			else if (arr[i][j] == '.' || arr[j][i] == '.')
			{
				dot_counter++;
			}
		}
	}
	if (S_counter > 0)
	{
		int temp;
		temp = c - S_counter;
		cout << dot_counter - temp << endl;
	}
	else
	{
		cout << dot_counter << endl;
	}

	return 0;
}

#define _USE_MATH_DEFINES
#include  <cstdio>
#include  <cstdlib>
#include  <iostream>
#include  <string>
#include  <vector>
#include  <set>
#include  <algorithm>
#include  <queue>
#include  <stack>
#include  <random>
#include  <map>
#include  <deque>

using namespace std;
typedef long double lld;

int main() {
	bool r1[10], c1[10];
	int r, c;
	char k;
	cin >> r >> c;
	for(int i = 0; i < r; i++)
	{
		for(int j = 0; j < c; j++)
		{
			cin >> k;
			if(k == 'S')
			{
				r1[i] = false;
				c1[j] = false;
			}
		}
	}
	int res[3] = {0, 0, 0};
	res[2] = r * c;
	for(int i = 0; i < r; i++)
		if(!r1[i])
			res[0]++;
	for(int i = 0; i < c; i++)
		if(!c1[i])
			res[1]++;
	cout << res[2] - res[1] * res[0];
	return 0;
}

#include<bits/stdc++.h>
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    int r,c,i=0,j=0,sum=0;
    cin>>r>>c;
    char x[r][c];
    for(i=0;i<r;i++)
    {
        for(j=0;j<c;j++)
            cin>>x[i][j];
    }
        for(i=0;i<r;i++)
    {
        for(j=0;j<c;j++)
            if(x[i][j]!='S')
                sum++;
    }
    cout<<sum-2;
    return 0;
}

//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;

#define     lli                 long long int
#define     ulli                unsigned long long int

#define     ifor(st,lim)        for(int i=st;i<lim;i++)
#define     jfor(stt,llim)      for(int j=stt;j<llim;j++)
#define		Test(tt)			for(int test=1;test<=tt;test++)
#define		For(var,srt,nnd)	for(var=srt;var<nnd;var++)
#define		Rfor(var,srt,nnd)	for(var=srt;var>=nnd;var--)

#define     pb                  push_back
#define     mkp                 make_pair
#define		all(var)			var.begin(),var.end()

#define     pi                  acos(-1)
#define     mod                 100000007

#define     Clear(var,val)      memset(var,val,sizeof(var))
#define     len(var)            (int)(var.length())
#define     vlen(vect)          (int)(vect.size())
#define     line(ss)            getline(cin,ss)

#define		FIO					ios_base::sync_with_stdio(false);cin.tie(NULL)

#define		sclock				int start_s=clock()
#define		eclock				int end_s=clock()
#define		pclock				printf("\nRuntime :: %.2lf\n", (double)(end_s-start_s)/CLOCKS_PER_SEC)

#define		iofile				freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)

/****************************** IO ************************************/
#define		ina(a)				scanf("%d",&a)
#define		inb(a,b)			scanf("%d %d",&a,&b)
#define		inc(a,b,c)			scanf("%d %d %d",&a,&b,&c)
#define		ins(chr)			scanf("%s",s)
#define		inlla(a)			scanf("%lld",&a)
#define		inllb(a,b)			scanf("%lld %lld",&a,&b)
#define		inllc(a,b,c)		scanf("%lld %lld %lld",&a,&b,&c)

#define		outa(a)				printf("%d",a)
#define		outlla(a)			printf("%lld",a)
#define		outs(s)				printf("%s",s)

#define		yn(b)				puts(b ? "YES" : "NO")

#define		outar(ar,ln,c)		for(int i=0;i<ln;i++){printf("%d%c",ar[i],c);}

#define		outCase()			printf("Case %d:",test)

#define		blank				printf("\n")
/**********************************************************************/

struct TP{

};

int main()
{
    FIO;
/******************************* A ************************************/

	int n,m,ans=0;
	inb(n,m);
	char ar[n][m];

	ifor(0,n) jfor(0,m) cin >> ar[i][j];

	bool b;
	ifor(0,n)
	{
		b=true;
		jfor(0,m) if(ar[i][j]=='S') b=false;
		if(b) jfor(0,m) ar[i][j]='*';
	}

	ifor(0,m)
	{
		b=true;
		jfor(0,n) if(ar[j][i]=='S') b=false;
		if(b) jfor(0,n) ar[j][i]='*';
	}

	ifor(0,n) jfor(0,m) if(ar[i][j]=='*') ans++;

	cout << ans << endl;

/**********************************************************************/
    return 0;
}

// Question Link - https://codeforces.com/problemset/problem/330/A

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int r, c, count = 0;
    int nr = 0, nc = 0, newr = 0;
    cin >> r >> c;
    char A[r][c];
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            cin >> A[i][j];
            if (A[i][j] == 'S')
            {
                nc++;
                newr = 1;
            }
        }
        if (newr)
            nr++;
        newr = 0;
    }
    cout << (r * c) - (nr * nc);

    return 0;
}

#include<iostream>
using namespace std;
int main()
{
	int r,c;
	cin>>r>>c;
	string a[r];
	char b[r][c];
	int i,j,ans=0;
	int count=0;
	int countc=0;
	for(i=0;i<r;i++)
	{
		cin>>a[i];
	}
	for(i=0;i<r;i++)
	{
		for(j=0;j<c;j++)
		{
			b[i][j]=a[i][j];
		}
	}
	for(i=0;i<r;i++)
	{
		for(j=0;j<c;j++)
		{
			if(b[i][j]=='S')
			{
				count+=1;
				break;
			}
	   }
    }
    for(i=0;i<c;i++)
    {
    	for(j=0;j<r;j++)
    	{
    		if(b[i][j]=='S')
    		{
    			countc+=1;
    			break;
    		}
    	}
    }
    ans=(r*c)-(count*countc);
    cout<<ans;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()

{
    int x,y,k,h,c=0,g=0,d=0;
    cin>>x>>y;
    char a[x][y];
    for(int i=0; i<x; i++)

        for (int j=0; j<y; j++)
        {
            cin>>a[i][j]; if (a[i][j]=='S')
            g++;
            if (a[i][j]!='S')
            d++;}

    for(int i=0; i<x; i++)
        for(int j=0; j<y; j++)
            if (a[i][j]=='S')
                continue;
                else c++;
    for(int j=0; j<y; j++)
        for(int i=0; i<x; i++)

            if (a[i][j]=='S')
                continue;
               else  c++;

if (d==0)
    cout<<"0";
else

    cout <<c/2-g;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    char a[n][m];
    int sum =0, count = 0,x=0,y=0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < n; i++){
        count = 0;
        for(int j = 0; j < m; j++){
            if(a[i][j]=='s'){
                count = 0;
                break;
            }
            else count++;
        }
        if(count>0)x++;
        sum += count;
    }
    for(int j = 0; j < m; j++){
        count = 0;
        for(int i = 0; i < n; i++){
            if(a[i][j]=='s'){
                count = 0;
                break;
            }
            else count++;
        }
        if(count>0)y++;
        sum += count;
    }
    sum -= max(x,y);
    cout << sum;
    return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int n,m;
    cin >> n >> m;
    string a[n];
    bool col[m];
    bool row[n];
    for (int r = 0 ; r<n ; r++) {
        row[r] = false;
        cin >> a[r];
        for (int c = 0 ; c<m ; c++) {
            if (a[r][c] == 'S') {
                col[c] = true;
                row[r] = true;
            }
        }
    }
    int mmd = 0;
    int cnt = 0;
    for (int i = 0 ; i<n ; i++) {
        if (!row[i]) {
            cnt += m;
            mmd++;
        }
    }
    for (int i = 0 ; i<m ; i++) {
        if (!col[i]) {
            cnt += n-mmd;
        }
    }
    cout << cnt;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int n,m,i,j;
    char c;
	cin>>n>>m;
	for (i=1;i<=n;i++) {
    for (j=1;j<=m;j++) {
    cin>>c;
    }
	}
	cout<<(n*m)-m<<endl;
return 0;
}

#include <cstdio>
int a,sat,sut,say,flag,flag1,say2,cod,mark[15][15];
char d[15][15];
int main()
{
	scanf("%d %d",&sat,&sut);
	for (int i = 0; i < sat; i++)
		for (int j = 0; j < sut; j++)
			scanf(" %c",&d[i][j]);

	for (int i = 0; i < sat; i++)
	{
		say=0;
		flag=0;
		for (int j = 0; j < sut; j++)
		{
			if(mark[i][j]==0)
			{
				say++;
				mark[i][j]=1;
			}
			if(d[i][j]=='S')
				flag=1;
		}
		if(flag==1)
		{
			for (int j = 0; j < sut; j++)
				mark[i][j]=0;
		}
		if(flag!=1)
			cod+=say;
	}
	for (int i = 0; i < sut; i++)
	{
		flag1=0;
		say2=0;
		for (int j = 0; j < sat; j++)
		{
			if(mark[i][j]==0)
			{
				say2++;
				mark[i][j]=1;
			}
			if(d[j][i]=='S')
			{
				flag1=1;
			}
		}
		if(flag1==1)
			for (int j = 0; j < sat; j++)
				mark[i][j]=0;
		if(flag1!=1)
			cod+=say2;
	}
	printf("%d",cod);
}

#include <iostream>

using namespace std;

char a[11][11];
int n,m,sum,cnt;
int main()
{
    cin >> n >> m;
    sum = n*m;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= m; ++j)
        {
            cin >> a[i][j];
        }
    }
    int p = 0;
    for (int i = 1; i <= n; ++i)
    {
        cnt = 0;
        for (int j = 1; j <= m; ++j)
        {
            if (a[i][j] == 'S')
            {
                sum--;
                ++p;
            }
            else
            {
                for (int q = j+1; q <= m; ++q)
                {
                    if (a[i][q] == 'S')
                        ++cnt;
                }
                for (int k = i+1; k <= n; ++k)
                {
                    if ( a[k][j] == 'S')
                        ++cnt;
                }
            }
            if ( cnt == 2)
                --sum;
        }
    }
    if (p == 0)
        cout << n*m;
    else if (p == n*m)
        cout << 0;
    else
    cout << sum+1;
}

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int a,b,c=0,d=0,ct=0,cp=0;
    bool str = false,flag = false;
    char m[30][30];
    cin >> a >> b;
    for(int i = 0;i < a;i++)
    {
        for(int j = 0;j < b;j++)
        {
            cin >> m[i][j];
            if(flag == false) cp++;
            if(m[i][j] == 'S')
            {
                cp = 0;
                flag = true;
            }
        }
        if(flag == false)
            for(int j = 0;j < b;j++)
                m[i][j] = '1';
        ct = ct + cp;
        flag = false;
    }
    flag = false;
    cp = 0;
    for(int j = 0;j < b;j++)
    {
        for(int i = 0;i < a;i++)
        {
            if(flag == false && m[i][j] != '1') cp++;
            if(m[i][j] == 'S')
            {
                cp = 0;
                flag = true;
            }
        }
        if(flag == false)
            for(int i = 0;i < a;i++)
                m[i][j] = '1';
        ct = ct + cp;
        flag = false;
    }

    cout << ct;
    return 0;
}

// Question Link - https://codeforces.com/problemset/problem/330/A

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int r, c, count = 0;
    int nr = 0, nc = 0, newr = 0, newc = 0;
    cin >> r >> c;
    char A[r][c];
    for (int i = 0; i < r; i++)
    {
        for (int j = 0; j < c; j++)
        {
            cin >> A[i][j];
            if (A[i][j] == 'S')
            {
                newc++;
                newr = 1;
            }
        }
        if (newr)
            nr++;
        newr = 0;
        if (newc > nc)
            nc = newc;
        newc = 0;
    }

    // cout << nr << " " << nc << endl;
    cout << (r * c) - (nr * nc);

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{    string s;
     cin>>s;

	 int length=s.length();
	 for(int i=2;i<=length-1;i=i+2)
	 {
	   char ch=s[i];
	   int ich= ch -'0';
	   int j=i-2;

	   while(j>=0 &&   s[j]-'0'>ich)
	    {

	   	s[j+2]=s[j];
	   	j=j-2;
	   }
	   s[j+2]= ch;
}
cout<<s;
return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main(){
int r,c,cnt,ans;
cin>>r>>c;
cnt=r*c;ans=0;
char cake[r][c];
for(int i=0;i<r;i++){
      for(int j=0;j<c;j++){
            cin>>cake[i][j];
      }}
for(int i=0;i<r;i++){
      for(int j=0;j<c;j++){
            if(cake[i][j]=='S'||cake[j][i]=='S'){
                        cnt=cnt-(r-1);
                        break;}}
                        ans=cnt;}
                        cout<<ans<<endl;
return 0 ;}

#include<iostream>
#include<vector>
using namespace std;
int main()
{
    long long int i,j,n,r,c,x,cnt=0,a1,a2;
    char ch;
    cin>>r>>c;
    for(i=1; i<=r; i++)
    {
        {
            for(j=1;j<=c;j++)
            {
                cin>>ch;
                if(ch=='S')
                    cnt++;
            }
        }
    }
    a1=r*c;
    a2=cnt*cnt;
    if(a2>a1)
        cout<<"0"<<endl;
    else
    cout<<a1-a2<<endl;
    return 0;
}

#include  <iostream>
using namespace std;
int main (){
	int n,m;
	cin>>n>>m;
	int sumb=n,sumc=m;
	char a [n][m];
	int b [n]={0},c [m]={0};
	for (int i=0;i <n;i++){
	for (int j=0;j<m;j++){
		cin>>a [i][j];
		if (a [i][j]=='S'){
		if (b [i]==0)
		sumb--;
		if (c [j]==0)
		sumc--;
		b [i]=-1;
		c [j]=-1;
		}
		else{
			if (b [i]==0)
			b [i]=1;
			if (c [j]==0)
			c [j]=1;
		}
	}
	}
	cout <<(m*sumb)+((sumc*n)-(sumb*sumc));
}

#include<bits/stdc++.h>
using namespace std;
#define debug(x) cerr<<#x<<'='<<x<<'\n'
int main()
{
int r,c,row,col,ans;
char arr[10][10];
cin>>r>>c;
row=r;
col=c;
for(int i=0;i<r;++i)
{
	for (int j=0;j<c;++j)
	{
		cin>>arr[i][j];
		if(arr[i][j]=='S')
		--row;
		//debug(row);

	}
	//cout<<row<<'\n';
}
ans=row*col;
//debug(ans);
//cout<<row;1
if(row!=0)
row=r-row;
else
row=r;
//debug(row);
for(int i=0;i<c;++i)
{
	for(int j=0;j<r;++j)
	{
		if(arr[j][i]=='S')
		{
			--col;
			j=r;
		}

	}
}
//debug(ans);
ans+=row*col;
if (ans>0)
cout<<ans<<'\n';
else
cout<<0<<'\n';

}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[10][10];
    int i,j,row,col,k=0,l=0;
    cin>>row>>col;
    for(i=0;i<row;i++)
    {
        for(j=0;j<col;j++)
        {
            cin>>a[i][j];
        }
    }
    i=0;j=0;
    while(i<row)
    {
        while(j<col)
        {
            if(a[i][j]=='s'||a[i][j]=='S')
            {
                k++;
                j=col;
            }
            j++;
        }
        j=0;i++;
    }
        i=0;j=0;
     while(j<col)
    {
        while(i<row)
        {
            if(a[i][j]=='s'||a[i][j]=='S')
            {
                l++;
                i=row;
            }
            i++;
        }
        i=0;j++;
    }
    cout<<row*l-k*l+col*k;
    return 0;
}

#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<cstring>
using namespace std;
int main(){
	int i,j,r,c,s=0,mo=0,ba=0;
	char a[100][100];
	cin>>r>>c;
	for(i=0;i<r;i++)
	for(j=0;j<c;j++){
		cin>>a[i][j];
		if(a[i][j]=='S') s++;
		}
	if(s==c*r) cout<<0;
	else if(s==0) cout<<r*c;
	else {
		for(i=0;i<r;i++){s=1;
			for(j=0;j<c;j++){
				if(s==0) break;
				if(a[i][j]=='S') s=0;
			}
			if(s==1) mo+=c;
	    }
		for(i=0;i<c;i++){s=1;
			for(j=0;j<r;j++){
				if(s==0) break;
				if(a[j][i]=='S') s=0;
			}
			if(s==1) ba+=r;
	    }
		int k;
		if(ba>mo) k=ba-mo;
		else k=mo-ba;
		cout<<ba+mo-k;
	}
}

#include <iostream>
using namespace std;

int main()
{
    int r,c,rr=0,cc=0,i,j,out;char x;
    cin>>r>>c;
    bool flag=false;//in case there exists multiple 's's in the same row
    for(j=0;j<r;j++)
    {
    for(i=0;i<c;i++)
    {
        if(flag)
        {
        cc++;
        flag=false;
        }
        cin>>x;
        if(x=='s')
        {
        rr++;
        flag=true;
        }

    }
    if(flag)
        cc++;
    flag=false;
}
out=(r-rr)*c+(c-cc)*rr;
cout<<out;
    // your code goes here
    return 0;
}

#include<iostream>
#include <map>
using namespace std;
int main(){
    int r,c,i;
    cin>> r>>c;
    map<int,int>mr;
    map<int,int>mc;
    char places[r][c];
    for(int i=0;i<r;i++){
        for(int j =0;j<c;j++){
            cin>>places[i][j];
            if(places[i][j]=='S'){
                mr[i];
                mr[j]; // make keys of all the rows/ columns which have strawberries -- cant be eaten
            }
        }
    }
    int total=r*c;
    if(mr.size() == 0 || mr.size() == r) {
        cout << total << endl;
        return 0;
    }
    int danger=(mr.size()*r -1) +(mc.size()*c-1);
    cout<<total-danger<<endl;
    return 0;
}

/**
 *  winners never quit
**/
#include <bits/stdc++.h>
using namespace std;
#define newline '\n'
#define space ' '
#define PQ priority_queue
#define VE vector
#define LL long long
#define ULL unsigned long long
#define pb push_back
#define mp make_pair
#define all(X) X.begin(), X.end()
#define II int, int
#define IS int, string
#define SI string, int
#define SS string, string
#define faster() {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
const double pi = acos(-1.0);

const int MAXN = 1;
bool check[11][11];
string S[11];

int main()
{
  faster()
  int t, ca = 0;
  int n, m;
  cin >> n >> m;
  //string S[n];
  for (int i = 0;i < n;i++)cin >> S[i];
  int r = 0;
  int c = 0;
  for (int i = 0;i < n;i++){
    bool ok_r = true;
    bool ok_c = true;
    for (int j = 0;j < m;j++){
      if (S[i][j] == 'S')ok_r = false;
      if (S[j][i] == 'S')ok_c = false;
    }
    if (ok_r){
      for (int j = 0;j < m;j++){
        if (check[i][j] == false){
          r++;
          check[i][j] == true;
        }
      }
    }
    if (ok_c){
      for (int j = 0;j < m;j++){
        if (check[j][i] == false){
          c++;
          check[j][i] = true;
        }
      }
    }
  }
  cout << (r+c) << newline;
  return 0;
}

#include <iostream>
#include <vector>
using namespace std ;
int main()
{
	int r , c ;
	char **arr ;
	cin>>r>>c ;
	arr = new char* [r] ;
	for( int i = 0 ; i < r ;i++)
	{
		arr[i] = new char [c] ;
	}
	for( int i = 0 ; i < r ; i++)
	{
		for( int j = 0 ; j< c ;j++ )
		{
			cin>>arr[i][j] ;
		}
	}
	int rn= 0 , cn = 0  ;
	for(int i = 0 ; i< r ; i++)
	{
		for(int j = 0; j< c ; j++)
		{
			if(arr[i][j]=='S'){
				rn++ ;
				cn++ ;
			}
		}
	}
	if(rn*cn > r*c)
		cout<<0<<endl ;
	else
		cout<<r*c - rn*cn<<endl ;
	return 0 ;
}

#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
# define ll long long
using namespace std;

ll N,M,cnt=0,cn=0; string S;
 vector < vector < ll > > G;

int main () {

 //   freopen ("input.txt","r",stdin);
   // freopen ("output.txt","w",stdout);

    cin >> N >> M;

    G.resize(N,vector < ll> (M));
    N--; M--;
  for (ll i=0; i<=N; i++) {

       cin >> S;

       for (ll j=0; j<=M; j++) {

            if (S[j]=='S')  {

              G[i][j]=1;

               if ( G[i][M]!=1)
                  G[i][M]=3;

                if ( G[0][j]!=1)
                G[0][j]=2;

            }
      }
  }
  N++; M++;
  for (ll i=0; i<M; i++ ) {

      if (G[0][i]==0 || G[0][i]==3 )
          cnt++;
           }

  for (ll j=1; j<N; j++ ) {

      if (G[j][M-1]==0 || G[j][M-1]==2 )
          cn++;

  }

  cout << (cnt*N)+(cn*(M-cnt));

return 0;
}

#include <iostream>
#include <vector>
using namespace std;

int main() {
	int n,m;
	cin >> n >> m;
	vector<int>v(n);
	char s[15][15];
	for(int i = 0 ; i < n ; i++)
	{
		for(int j = 0 ; j < m ; j++)
		{
			cin >> s[i][j];
		}
	}
	int cnt = 0;
	for(int i = 0 ; i < n ; i++)
	{
		for(int j = 0 ; j < m ; j++)
		{
			if(s[i][j] == 'S') cnt++;
		}
	}
	cout << (n * m) - (cnt * 2) << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std ;
char m[10][10] ;
main ()
{
    int r, c, cnt = 0 ;
    cin >> r >> c ;
    for ( int i = 0 ; i < r ; i++ )
        for ( int j = 0 ; j < c ; j++ )
            cin >> m[i][j] ;

    for ( int i = 0 ; i < r ; i++ )
        for ( int j = 0 ; j < c ; j++ )
        {
            if ( m[i][j] == 's')
                break ;
            else
                cnt++ ;
        }

    for ( int i = 0 ; i < c ; i++ )
        for ( int j = 0 ; j < r ; j++ )
        {
            if ( m[i][j] == 'S' )
                break ;
            else
                cnt++ ;
        }

        cout << cnt << endl ;
}

#include <iostream>
using namespace std;
int main (){
    int r,c;
    cin >> r >> c;
    int Inr = 0,Inc = 0;
    int *Numr = new int[r];
    int *Numc = new int[c];
    char x;
    for (int i = 0; i < r; i++){
        for (int j = 0; j < c; j++){
            cin >> x;
            if (x == 'S'){
              Numr[Inr] = i;
              Numc[Inc] = j;
              Inr++;
              Inc++;
            }
        }
    }

    int res = 0,Totalr = Inr, Totalc = Inc;
    for (int i = 0; i < Inr; i++){
   //     cout << Numr[i] << " "<< Numc[i] << endl;
        for (int j = i+1; j < Inr; j++){
            if (Numr[i] == Numr [j] && Numr[j] != -1){
               Totalr--;
               Numr[j] = -1;
            }
            if (Numc[i] == Numc [j] && Numc[j] != -1){
               Totalc--;
               Numc[j] = -1;
            }
        }
    }
    int Fuck1 = r - Totalr;
    int Fuck2 = c - Totalc;
    int xx = Fuck1 * c;
    int y = Fuck2 * r ;
//    cout << Fuck1 << " " << Fuck2 << " " << Totalr << " " << Totalc << endl;
    cout << (xx + y) - (Fuck1 * Fuck2)<<endl;
//    system("PAUSE");
    return 0;
    }

#include <iostream>
using namespace std;
int main()
{
    int r,c,x=0,a=0,f=0,counter=0; char cake[10][10];
    cin>>r>>c;
    for(int i=0;i<r;i++)
        for(int j=0;j<c;j++)
            cin>>cake[i][j];
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            if(cake[i][j]!='S')
                x++;}
        if(x==c)
            for(int j=0;j<c;j++)
                cake[i][j]='X';
        x=0; }
    for(int j=0;j<c;j++){
        for(int j=0;j<c;j++){
        if(cake[j][a]!='S')
            f++; }
        if(x==c){
            for(int i=0;i<r;i++)
                cake[i][j]='X';}
        f=0;
        a++;}
    for(int i=0;i<r;i++)
        for(int j=0;j<c;j++)
            if(cake[i][j]=='X')
                counter++;
    cout<<counter<<endl;
    return 0;
}