#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long a[1001], b[1001], c[1001], d[1001];
char s[1001];
long long ans, tot;
long long calc() {
  long long cc = 0;
  for (long long i = 1; i <= n; i++)
    if (c[i]) {
      ans += (c[i] - 1) * (m - c[i]) * 4;
      for (long long j = i + 1; j <= n; j++)
        if (!c[j] || c[j] < c[j - 1])
          break;
        else
          cc += (c[i] - 1) * (m - c[j]) * 4;
      for (long long j = i + 1; j <= n; j++)
        if (!c[j] || c[j] > c[j - 1])
          break;
        else
          cc += (c[j] - 1) * (m - c[i]) * 4;
    }
  return cc;
}
int main() {
  scanf("%I64d%I64d", &n, &m);
  for (long long i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    for (long long j = 1; j <= m; j++)
      if (s[j] == '.')
        tot++, a[i]++, b[j]++;
      else
        c[i] = j, d[j] = i;
  }
  long long o, ct, su;
  o = ct = su = 0;
  for (long long i = 1; i <= n; i++) {
    o += su * a[i];
    ct += a[i];
    su += ct;
  }
  ans = o * 2;
  o = ct = su = 0;
  for (long long i = 1; i <= m; i++) {
    o += su * b[i];
    ct += b[i];
    su += ct;
  }
  ans += o * 2;
  ans += calc();
  swap(n, m);
  for (long long i = 1; i <= n; i++) c[i] = d[i];
  ans += calc();
  printf("%.20lf", ((double)ans) / tot / tot);
}
