#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, j, k, l, x, y[100000];
  char c;
  cin >> n >> m;
  k = n;
  l = m;
  x = n;
  y[0] = m;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> c;
      if (c == 'S') {
        if (i != x) k--;
        if (j != y[j]) l--;
        x = i;
        y[j] = j;
      }
    }
  }
  int ans = k * m + (l * n) - (l * k);
  if (ans < 0) ans = 0;
  cout << ans << endl;
}
