#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, c;
  cin >> r >> c;
  vector<string> v(r);
  for (int i = 0; i < r; i++) {
    cin >> v[i];
  }
  int ans = 0;
  for (int i = 0; i < r; i++) {
    int ct = 0;
    bool a = true;
    for (int j = 0; j < c; j++) {
      if (v[i][j] == '.') {
        ct++;
      }
      if (v[i][j] == 'S') a = false;
    }
    if (a) {
      ans += ct;
      for (int j = 0; j < c; j++)
        if (v[i][j] == '.') v[i][j] = '*';
    }
  }
  for (int i = 0; i < c; i++) {
    int ct = 0;
    bool a = true;
    for (int j = 0; j < r; j++) {
      if (v[j][i] == '.') {
        ct++;
      }
      if (v[j][i] == 'S') a = false;
    }
    if (a) ans += ct;
  }
  cout << ans << endl;
  return 0;
}
