#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, c;
  cin >> r >> c;
  int t = 0;
  int x = c - 1, y = r - 1;
  vector<vector<char> > v(r, vector<char>(c));
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> v[i][j];
    }
  }
  for (int i = 0; i < r; i++) {
    int a = 0, b = 0, d = 0;
    for (int j = 0; j < c; j++) {
      if (v[i][j] == 'S') a++;
      if (v[i][j] == '.') b++;
      if (v[i][j] == 'x') d++;
    }
    for (int j = 0; j < c; j++) {
      if (a == 0 && d < c) v[i][j] = 'x';
      if (a == 0 && d < c && j == x) t += b;
    }
  }
  for (int i = 0; i < c; i++) {
    int a = 0, b = 0, d = 0;
    for (int j = 0; j < r; j++) {
      if (v[j][i] == 'S') a++;
      if (v[j][i] == '.') b++;
      if (v[j][i] == 'x') d++;
    }
    for (int j = 0; j < r; j++) {
      if (a == 0 && d < r) v[j][i] = 'x';
      if (a == 0 && d < r && j == y) t += b;
    }
  }
  cout << t << '\n';
  return 0;
}
