#include <bits/stdc++.h>
using namespace std;
int main() {
  set<int> c;
  set<int> r;
  pair<int, int> p[22];
  char a[22][22];
  int b[22][22] = {0}, i, j, num = 0, n, m, k = 0, v = 0, num1 = 0, num2 = 0;
  memset(p, -1, sizeof(p));
  cin >> n >> m;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) {
      cin >> a[i][j];
      if (a[i][j] == 'S') {
        r.insert(i);
        c.insert(j);
        num2++;
      }
    }
  cout << m * n - (r.size() * c.size());
}
