#include <bits/stdc++.h>
using namespace std;
const int N = 2002;
long long sum, cnt, ans;
int n, m, i, j, tot, A[N], B[N], l, r;
char s[N];
void find(int *a, int n, int m) {
  for (int i = 1; i <= n; i++) {
    sum = 0;
    for (int j = 1; j <= n; j++) sum += (m - (a[j] > 0)) * abs(i - j);
    ans += (m - (a[i] > 0)) * sum;
    if (a[i]) {
      cnt = m - a[i];
      for (l = i - 1; a[l] > a[l + 1]; l--) cnt += m - a[l];
      for (r = i + 1; a[r] > a[r - 1]; r++) cnt += m - a[r];
      ans += 4 * cnt * (a[i] - 1);
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    for (j = 1; j <= m; j++)
      if (s[j] == 'X')
        A[i] = j, B[j] = i;
      else
        tot++;
  }
  find(A, n, m), find(B, m, n);
  printf("%.7lf", ans * 1.0 / tot / tot);
}
