#include <bits/stdc++.h>
int main() {
  int r, c, i, j, k, d, e = 0, f, g = 0;
  scanf("%d %d", &r, &c);
  char s[r][c];
  for (i = 0; i < r; i++) {
    scanf("%s", s[i]);
  }
  for (i = 0; i < r; i++) {
    d = 0;
    for (j = 0; j < c; j++) {
      if (s[i][j] == 'S')
        break;
      else if (s[i][j] == '.')
        d++;
    }
    if (d == c) e++;
  }
  for (i = 0; i < c; i++) {
    f = 0;
    for (j = 0; j < r; j++) {
      if (s[j][i] == 'S')
        break;
      else if (s[j][i] == '.')
        f++;
    }
    if (f == r) g++;
  }
  printf("%d", (c * e) + (g * r) - (e * g));
}
