#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5, oo = 0x3f3f3f3f;
const long long M = 1e12 + 105;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};
int main() {
  int c, r, ans = 0;
  scanf("%d %d", &r, &c);
  char second[r][c];
  for (int i = 0; i < r; i++) scanf("%s", second[i]);
  for (int i = 0; i < r; i++) {
    int cc = 0;
    for (int j = 0; j < c; j++)
      if (second[i][j] == 'S')
        break;
      else if (second[i][j] == '.')
        cc++;
    if (cc == c) {
      ans += cc;
      for (int j = 0; j < c; j++) second[i][j] = 'X';
    }
  }
  for (int i = 0; i < c; i++) {
    bool ff = false;
    int cc = 0;
    for (int j = 0; j < r; j++)
      if (second[j][i] == 'S') {
        ff = true;
        break;
      } else if (second[j][i] == '.')
        cc++, second[j][i] = 'X';
    if (!ff) ans += cc;
  }
  printf("%d\n", ans);
  return 0;
}
