#include <bits/stdc++.h>
using namespace std;
using LL = long long;
char a[1005][1005];
LL gao(int pos[], int n, int m) {
  LL ret = 0, lhs = 0, rhs = 0;
  for (int i = 0; i < n; i++)
    if (~pos[i]) {
      lhs += pos[i];
      ret += pos[i] * rhs + lhs * (m - pos[i] - 1);
      rhs += m - pos[i] - 1;
      if (pos[i + 1] < pos[i]) lhs = 0;
      if (pos[i + 1] > pos[i] || pos[i + 1] < 0) rhs = 0;
    }
  return ret * 4;
}
int main() {
  int n, m, cnt = 0, row[1005], col[1005];
  scanf("%d%d", &n, &m);
  for (int i = 0; i < 1005; i++) row[i] = col[i] = -1;
  for (int i = 0; i < n; i++) {
    scanf("%s", a[i]);
    for (int j = 0; j < m; j++)
      if (a[i][j] == 'X') row[col[j] = i] = j, cnt++;
  }
  LL sum = 0, all = (n * m - cnt) * LL(n * m - cnt);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < i; j++)
      sum += (i - j) * (m - (row[i] >= 0)) * (m - (row[j] >= 0)) * 2;
  for (int i = 0; i < m; i++)
    for (int j = 0; j < i; j++)
      sum += (i - j) * (n - (col[i] >= 0)) * (n - (col[j] >= 0)) * 2;
  sum += gao(row, n, m) + gao(col, m, n);
  printf("%.15f\n", sum * 1.0 / all);
}
