#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, c, i, j, ans = 0;
  map<int, int>::iterator it;
  scanf("%d %d", &r, &c);
  char cake[r][c];
  map<int, int> row, column;
  for (i = 0; i < r; i++) {
    for (j = 0; j < c; j++) {
      scanf("%c", &cake[i][j]);
      while (cake[i][j] == '\n') scanf("%c", &cake[i][j]);
      if (cake[i][j] == 'S') {
        row[i] = j;
        column[j] = i;
      }
    }
  }
  for (i = 0; i < r; i++) {
    if (row.find(i) == row.end()) {
      for (j = 0; j < c; j++) {
        if (cake[i][j] == '.') {
          ans++;
          cake[i][j] = 'x';
        }
      }
    }
  }
  for (i = 0; i < c; i++) {
    if (column.find(i) == column.end()) {
      for (j = 0; j < r; j++) {
        if (cake[j][i] == '.') {
          ans++;
          cake[j][i] = 'x';
        }
      }
    }
  }
  printf("%d\n", ans);
}
