#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, c, sum = 0, SUM = 0;
  cin >> r >> c;
  bool m, k = 1;
  char x[r][c];
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> x[i][j];
      if (x[i][j] == 'S') {
        k = 0;
        (x[i][0] != 'S') ? x[i][0] = 'i' : x[i][0] = 'S';
      }
    }
  }
  for (int i = 0; i < r; i++) {
    sum = 0;
    k = 1;
    m = 1;
    for (int j = 0; j < c; j++) {
      if (x[i][j] == 'S' || x[i][j] == 'i') {
        k = 0;
        m = 0;
        sum = 0;
        break;
      } else if (m) {
        sum++;
        x[i][j] = 'd';
      }
    }
    if (k) {
      SUM += sum;
    }
  }
  for (int i = 0; i < c; i++) {
    sum = 0;
    k = 1;
    for (int j = 0; j < r; j++) {
      if (x[j][i] == 'S') {
        sum = 0;
        k = 0;
        break;
      } else if (x[j][i] == 'd') {
        ;
      } else {
        sum++;
      }
    }
    if (k) {
      SUM += sum;
    }
  }
  cout << SUM << endl;
  return 0;
}
