#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long llINF = 1e18;
const int MAXN = 1005;
int n, m, cnt;
int col[MAXN], row[MAXN];
char s[MAXN];
long long Calc(int n, int m, int *a) {
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    long long sum = 0, num = m - a[i];
    for (int j = 1; j <= n; j++) sum += 1ll * (m - (a[j] ? 1 : 0)) * abs(i - j);
    res += (m - (a[i] ? 1 : 0)) * sum;
    if (a[i]) {
      int l = i - 1, r = i + 1;
      while (a[l] > a[l + 1]) {
        num += m - a[l];
        l -= 1;
      }
      while (a[r] > a[r - 1]) {
        num += m - a[r];
        r += 1;
      }
      res += 2ll * 2 * num * (a[i] - 1);
    }
  }
  return res;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    for (int j = 1; j <= m; j++) {
      if (s[j] == 'X') {
        cnt += 1;
        row[i] = j;
        col[j] = i;
      }
    }
  }
  long double ans =
      1.0 * (Calc(n, m, row) + Calc(m, n, col)) / (n * m - cnt) / (n * m - cnt);
  cout << setprecision(7) << ans << endl;
  return 0;
}
