#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  char a[n + 1][m + 1];
  int f = 0;
  int t = 0;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < s.size(); j++) {
      a[i][j + 1] = s[j];
      if (s[j] == '#') f = 1;
      if (s[j] == '.') t++;
    }
  }
  if (f == 0) {
    cout << n + m - 2;
    return 0;
  }
  cout << t - 2;
  return 0;
}
