#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int r, c;
  char **a;
  cin >> r >> c;
  a = new char *[r];
  int count = 0;
  for (int i = 0; i < r; i++) {
    a[i] = new char[c];
    bool flag = true;
    for (int j = 0; j < c; j++) {
      cin >> a[i][j];
      if (a[i][j] == 'S') {
        flag = false;
      }
    }
    if (flag) {
      count += c;
    }
  }
  int c1 = count;
  for (int i = 0; i < c; i++) {
    bool flag = true;
    for (int j = 0; j < r; j++) {
      if (a[j][i] == 'S') {
        flag = false;
      }
    }
    if (flag) {
      count += r;
    }
  }
  count -= ((count - c1) / r) * (c1 / c);
  cout << count << endl;
  return 0;
}
