#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  char s[n][m];
  int rc = 0, cc = 0, temp;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    temp = 0;
    for (int j = 0; j < m; j++) {
      if (s[i][j] == 'S')
        break;
      else
        temp++;
    }
    if (temp == m) rc++;
  }
  for (int i = 0; i < m; i++) {
    temp = 0;
    for (int j = 0; j < n; j++) {
      if (s[j][i] == 'S')
        break;
      else
        temp++;
    }
    if (temp == n) cc++;
  }
  cout << rc * m + cc * (n - rc);
}
