#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, c;
  cin >> r >> c;
  set<int> row;
  set<int> col;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      char c;
      cin >> c;
      if (c == 'S') {
        row.insert(i);
        col.insert(j);
      }
    }
  }
  int x = row.size();
  int y = col.size();
  int ans = (r - x) * c + (c - y) * r - (r - x) * (c - y);
  cout << max(ans, 0) << endl;
}
