#include <bits/stdc++.h>
const int MAXN = 1005;
int n, m, cnt, a[MAXN], b[MAXN];
char s[MAXN];
inline double solve(int n, int m, int *a) {
  register long long res = 0, now;
  register double ans = 0;
  for (register int i = 0; i < n; i++) {
    for (register int j = 0; j < i; j++) res += (i - j) * (m - (a[j] >= 0));
    for (register int j = i; j < n; j++) res += (j - i) * (m - (a[j] >= 0));
    ans += res * (m - (a[i] >= 0)), res = 0;
  }
  for (register int i = 0; i < n; i++) {
    if (a[i] >= 0) {
      now = a[i];
      for (register int j = i; j >= 0 && a[j] >= now; j--)
        now = a[j], res += m - 1 - now;
      now = a[i];
      for (register int j = i + 1; j < n && a[j] > now; j++)
        now = a[j], res += m - 1 - now;
      ans += res * a[i] * 4, res = 0;
    }
  }
  return ans;
}
int main() {
  std::ios::sync_with_stdio(false), std::cin >> n >> m, cnt = n * m;
  for (register int i = 0; i < n || i < m; i++) a[i] = b[i] = -1;
  for (register int i = 0, j; i < n; i++)
    for (std::cin >> s, j = 0; j < m; j++)
      if (s[j] == 'X') a[i] = j, b[j] = i, cnt--;
  std::cout << std::fixed << std::setprecision(9)
            << (solve(n, m, a) + solve(m, n, b)) / cnt / cnt;
  return 0;
}
