#include <bits/stdc++.h>
using namespace std;
char s[2005][2005];
int h[2005], l[2005];
long long sum;
int block;
int abss(int x) {
  if (x > 0) return x;
  return -x;
}
long long cal(int n, int m, int *a) {
  long long ret = 0;
  for (int i = 1; i <= n; i++) {
    int jia = 0, y = m - a[i];
    for (int j = 1; j <= n; j++) {
      if (i != j) {
        if (a[j])
          jia += (m - 1) * abss(i - j);
        else
          jia += m * abss(i - j);
      }
    }
    if (a[i])
      ret += 1ll * jia * (m - 1);
    else
      ret += 1ll * jia * m;
    int l = i - 1, r = i + 1;
    if (a[i]) {
      while (a[l] > a[l + 1]) {
        y += m - a[l];
        l--;
      }
      while (a[r] > a[r - 1]) {
        y += m - a[r];
        r++;
      }
      ret += 4 * (a[i] - 1) * y;
    }
  }
  return ret;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  for (int i = 1; i <= n; i++) {
    int he = 0, now = 0;
    for (int j = 1; j <= m; j++) {
      if (s[i][j] == 'X') {
        h[i] = j;
        l[j] = i;
        block++;
      }
    }
  }
  int S = n * m - block;
  double res = (double)(cal(n, m, h) + cal(m, n, l)) / S / S;
  printf("%.10lf\n", res);
  return 0;
}
