#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e3 + 3;
long long n, m, hang[maxn], lie[maxn];
char str[maxn];
inline long long find(long long n, long long m, long long a[]) {
  long long res = 0;
  for (long long i = (1); i <= (n); ++i) {
    long long sum = 0;
    for (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], 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() {
  long long Dnum = 0, Snum;
  scanf("%lld%lld", &n, &m);
  for (long long i = (1); i <= (n); ++i) {
    scanf("%s", str + 1);
    for (long long j = (1); j <= (m); ++j)
      if (str[j] == 'X') hang[i] = j, lie[j] = i, Dnum++;
  }
  Snum = ((n * m) - Dnum) * ((n * m) - Dnum);
  double ans = (find(n, m, hang) * 1.0 + find(m, n, lie) * 1.0) / (Snum * 1.0);
  return printf("%.12lf\n", ans), 0;
}
