#include <bits/stdc++.h>
using namespace std;
void solve() {
  int r, c;
  char cell[11][11];
  int srpos[122];
  int scpos[122];
  int l = 0, m = 0;
  cin >> r >> c;
  for (int i = 1; i <= r; i++)
    for (int j = 1; j <= c; j++) {
      cin >> cell[i][j];
      if (cell[i][j] == 'S') {
        srpos[l] = i;
        scpos[m] = j;
        l++;
        m++;
      }
    }
  int ans = 0, dec = 0;
  ;
  sort(scpos, scpos + m);
  l = 0, m = 0;
  for (int i = 1; i <= r; i++) {
    if (i == srpos[l]) {
      while (srpos[l] == i) l++;
      continue;
    } else {
      ans += c;
      dec++;
    }
  }
  for (int j = 1; j <= c; j++) {
    if (j == scpos[m]) {
      while (scpos[m] == j) m++;
      continue;
    } else
      ans += r - dec;
  }
  cout << ans;
}
int main() { solve(); }
