#include <bits/stdc++.h>
const int N = 1010;
int l[N], r[N];
char map[N][N];
int main() {
  int n, m, i, j, s;
  long long ans = 0, sum;
  scanf("%d %d", &n, &m);
  for (i = 0; i < n; i++) scanf("%s", map[i]);
  memset(l, 0, sizeof(l));
  memset(r, 0, sizeof(r));
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      if (map[i][j] == 'X') {
        l[i + 1] = j + 1;
        r[j + 1] = i + 1;
      }
  sum = s = 0;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      if (map[i][j] == '.') {
        ans += (i + 1) * s - sum;
        s++;
        sum += i + 1;
      }
  sum = s = 0;
  for (i = 0; i < m; i++)
    for (j = 0; j < n; j++)
      if (map[j][i] == '.') {
        ans += (i + 1) * s - sum;
        s++;
        sum += i + 1;
      }
  for (i = 1; i <= n; i++)
    if (l[i] != 0) {
      ans += 2 * (l[i] - 1) * (m - l[i]);
      for (j = i + 1; j <= n; j++) {
        if (l[j] == 0 || l[j] < l[j - 1]) break;
        ans += 2 * (l[i] - 1) * (m - l[j]);
      }
      for (j = i + 1; j <= n; j++) {
        if (l[j] == 0 || l[j] > l[j - 1]) break;
        ans += 2 * (l[j] - 1) * (m - l[i]);
      }
    }
  for (i = 1; i <= m; i++)
    if (r[i] != 0) {
      ans += 2 * (r[i] - 1) * (n - r[i]);
      for (j = i + 1; j <= m; j++) {
        if (r[j] == 0 || r[j] < r[j - 1]) break;
        ans += 2 * (r[i] - 1) * (n - r[j]);
      }
      for (j = i + 1; j <= m; j++) {
        if (r[j] == 0 || r[j] > r[j - 1]) break;
        ans += 2 * (r[j] - 1) * (n - r[i]);
      }
    }
  printf("%.9lf", double(ans * 2) / double(s) / double(s));
  return (0);
}
