#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y;
  char z;
  cin >> x >> y;
  vector<vector<char> > v(x, vector<char>(y));
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < y; j++) {
      cin >> z;
      v[i][j] = z;
    }
  }
  int c = 0;
  for (int i = 0; i < x; i++) {
    int cc = 0;
    for (int j = 0; j < y; j++) {
      if (v[i][j] == '.') {
        cc++;
        v[i][j] = 'x';
      }
      if (v[i][j] == 'S') {
        cc = 0;
        for (int g = 0; g < j; g++) v[i][g] = '.';
        break;
      }
    }
    c += cc;
  }
  for (int i = 0; i < y; i++) {
    int cc = 0;
    for (int j = 0; j < x; j++) {
      if (v[j][i] == '.') {
        cc++;
        v[j][i] = 'x';
      }
      if (v[j][i] == 'S') {
        cc = 0;
        break;
      }
    }
    c += cc;
  }
  cout << c << endl;
  return 0;
}
