#include <bits/stdc++.h>
using namespace std;
const long long N = 1e3 + 5;
long long n, m, tot;
long long hang[N], lie[N];
double sum, ans;
char str[N];
long long find(long long n, long long m, long long a[]) {
  long long res = 0;
  for (register long long i = 1; i <= n; ++i) {
    long long sum = 0;
    for (register long long j = 1; j <= n; ++j) {
      if (a[j])
        sum += (m - 1) * abs(j - i);
      else
        sum += m * abs(j - i);
    }
    if (a[i])
      res += (m - 1) * sum;
    else
      res += m * sum;
    if (a[i]) {
      long long cnt = m - a[i];
      long long l = i, r = i;
      while (a[l] < a[l - 1]) {
        cnt += m - a[l - 1];
        l--;
      }
      while (a[r] < a[r + 1]) {
        cnt += m - a[r + 1];
        r++;
      }
      res += 4 * (a[i] - 1) * cnt;
    }
  }
  return res;
}
signed main() {
  scanf("%lld%lld", &n, &m);
  for (register long long i = 1; i <= n; ++i) {
    scanf("%s", str + 1);
    for (register long long j = 1; j <= m; ++j)
      if (str[j] == 'X') {
        hang[i] = j;
        lie[j] = i;
        tot++;
      }
  }
  sum = (double)n * m - tot;
  ans = (double)(find(n, m, hang) + find(m, n, lie)) / sum / sum;
  printf("%.6f\n", ans);
  return 0;
}
