#include <bits/stdc++.h>
int N, M, i, j, Cnt;
int A[1005], B[1005];
char Map[1005][1005];
double Work(int N, int M, int *A) {
  int i, j;
  double Ans = 0, res;
  for (i = 0; i < N; ++i) {
    res = 0;
    for (j = i - 1; j >= 0; --j) res += (i - j) * (M - (A[j] >= 0));
    for (j = i + 1; j < N; ++j) res += (j - i) * (M - (A[j] >= 0));
    Ans += res * (M - (A[i] >= 0));
  }
  for (i = 0; i < N; ++i)
    if (A[i] >= 0) {
      res = M - A[i] - 1;
      for (j = i - 1; j >= 0 && A[j] > A[j + 1]; --j) res += M - A[j] - 1;
      for (j = i + 1; j < N && A[j] > A[j - 1]; ++j) res += M - A[j] - 1;
      Ans += 4 * A[i] * res;
    }
  return Ans;
}
int main() {
  scanf("%d%d", &N, &M);
  Cnt = N * M;
  for (i = 0; i < N; ++i) scanf("%s", Map[i]);
  for (i = 0; i < N; ++i) A[i] = -1;
  for (i = 0; i < M; ++i) B[i] = -1;
  for (i = 0; i < N; ++i)
    for (j = 0; j < M; ++j)
      if (Map[i][j] == 'X') A[i] = j, B[j] = i, --Cnt;
  printf("%.12lf\n", (Work(N, M, A) + Work(M, N, B)) / Cnt / Cnt);
  return 0;
}
