#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  bool b = false;
  cin >> n >> m;
  char arr[10][10], trans[10][10];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> arr[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (arr[i][j] == 'S') {
        b = true;
        break;
      }
    }
    if (b) {
      b = false;
      continue;
    } else {
      for (int j = 0; j < m; j++) {
        arr[i][j] = 'a';
      }
    }
    b = false;
  }
  b = false;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      trans[i][j] = arr[j][i];
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (trans[i][j] == 'S') {
        b = true;
        break;
      }
    }
    if (b) {
      b = false;
      continue;
    } else {
      for (int j = 0; j < n; j++) {
        trans[i][j] = 'a';
      }
    }
    b = false;
  }
  int counter = 0;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (trans[i][j] == 'a') {
        counter++;
      }
    }
  }
  cout << counter;
  return 0;
}
