#include <bits/stdc++.h>
using namespace std;
int search(vector<long long> v, long long m, int n) {
  int start = 0;
  int ans = -1;
  while (start <= n) {
    int mid = (start + n) / 2;
    if (v[mid] <= m)
      start = mid + 1;
    else {
      ans = mid;
      n = mid - 1;
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, t, sum = 0;
  cin >> n >> t;
  char s[n][t];
  for (int i = 0; i < n; i++) {
    for (long long j = 0; j < t; j++) cin >> s[i][j];
  }
  bool flag = 0;
  for (int i = 0; i < t; i++) {
    flag = 0;
    for (long long j = 0; j < n; j++) {
      if (s[j][i] == 'S') {
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      for (long long j = 0; j < n; j++) {
        if (s[j][i] != 'S') {
          if (s[j][i] == '.') sum++;
          s[j][i] = '#';
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    flag = 0;
    for (long long j = 0; j < t; j++) {
      if (s[i][j] == 'S') {
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      for (long long j = 0; j < t; j++) {
        if (s[i][j] != 'S') {
          if (s[i][j] == '.') sum++;
          s[i][j] = '#';
        }
      }
    }
  }
  cout << sum;
}
