#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, c, counter = 0, cntC, cntR;
  char n;
  cin >> r >> c;
  cin.get(n);
  char map[c][r];
  bool columns[c], rows[r];
  for (int i = 0; i < c; i++) columns[i] = false;
  for (int i = 0; i < r; i++) rows[i] = false;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin.get(map[j][i]);
      if (map[j][i] == 'S') {
        columns[j] = true;
        rows[i] = true;
      }
    }
    cin.get(n);
  }
  for (cntC = 0; cntC < c; cntC++) {
    if (!columns[cntC])
      for (int i = 0; i < r; i++) {
        if (map[cntC][i] == '.') {
          counter++;
          map[cntC][i] = 'o';
        }
      }
  }
  for (cntR = 0; cntR < r; cntR++) {
    if (!rows[cntR])
      for (int i = 0; i < c; i++) {
        if (map[i][cntR] == '.') {
          counter++;
          map[i][cntR] = 'o';
        }
      }
  }
  cout << counter;
}
