#include <bits/stdc++.h>
using namespace std;
bool lenear_search(vector<int> cln, int val) {
  for (int l = 0; l < cln.size(); l++) {
    if (cln[l] == val) {
      return false;
    }
  }
  return true;
}
int main() {
  int row, col;
  scanf("%d %d ", &row, &col);
  char val;
  vector<int> pos;
  int ans = 0;
  int xl = row;
  bool flag = true;
  for (int l = 1; l <= row; l++) {
    flag = true;
    for (int i = 1; i <= col; i++) {
      cin >> val;
      if (val == 'S') {
        flag = false;
        pos.push_back(i);
      }
    }
    if (flag == true) {
      ans += col;
      xl--;
    }
  }
  for (int l = 1; l <= col; l++) {
    if (lenear_search(pos, l) == true) {
      ans += xl;
    }
  }
  cout << ans << endl;
  return 0;
}
