#include <bits/stdc++.h>
using namespace std;
long long GCD(long long u, long long v) {
  long long r;
  while (v) {
    r = u % v;
    u = v;
    v = r;
  }
  return u;
}
long long modpow(long long a, long long p, long long mod) {
  long long ret = 1;
  while (p) {
    if (p & 1) ret = (ret * a) % mod;
    a = (a * a) % mod;
    p /= 2;
  }
  return ret;
}
long long power(long long a, long long p) {
  long long ret = 1;
  while (p) {
    if (p & 1) ret = (ret * a);
    a = (a * a);
    p /= 2;
  }
  return ret;
}
int main() {
  int i, j, tmp;
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  string s[11];
  int n, m, cnt = 0;
  cin >> n >> m;
  for (i = 0; i < n; i++) cin >> s[i];
  for (i = 0; i < n; i++) {
    int fl = 0;
    for (j = 0; j < m; j++) {
      if (s[i][j] == '.') fl++;
      if (s[i][j] == 'S') {
        fl = 0;
        break;
      }
    }
    if (fl) {
      cnt += fl;
      for (j = 0; j < m; j++) s[i][j] = 'x';
    }
  }
  for (j = 0; j < m; j++) {
    int fl = 0;
    for (i = 0; i < n; i++) {
      if (s[i][j] == '.') fl++;
      if (s[i][j] == 'S') {
        fl = 0;
        break;
      }
    }
    if (fl) {
      cnt += fl;
      for (i = 0; i < n; i++) s[i][j] = 'x';
    }
  }
  cout << cnt << endl;
  return 0;
}
