#include <bits/stdc++.h>
using namespace std;
const int u = 1010;
char a[u][u];
int b[u], c[u], n, m, t, i, j;
long long ans;
inline int calc(int i) { return i * (i + 1) / 2; }
void solve(int n, int m, int b[u]) {
  for (i = 1; i <= n; i++)
    if (b[i]) {
      ans += (b[i] - 1) * (m - b[i]) * 4;
      for (j = i - 1; j; j--)
        if (b[j] && b[j] < b[j + 1])
          ans += (m - b[i]) * (b[j] - 1) * 4;
        else
          break;
      for (j = i + 1; j <= n; j++)
        if (b[j] && b[j] < b[j - 1])
          ans += (m - b[i]) * (b[j] - 1) * 4;
        else
          break;
    }
}
int main() {
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    scanf("%s", a[i] + 1);
    for (j = 1; j <= m; j++)
      if (a[i][j] == '.')
        t++, ans +=
             m * (calc(i - 1) + calc(n - i)) + n * (calc(j - 1) + calc(m - j));
      else
        b[i] = j, c[j] = i;
  }
  for (i = 1; i <= n; i++)
    if (b[i])
      for (j = 1; j <= n; j++)
        ans -= m * abs(i - j) + calc(b[i] - 1) + calc(m - b[i]) -
               (b[j] > 0) * (abs(i - j) + abs(b[i] - b[j]));
  solve(n, m, b);
  solve(m, n, c);
  printf("%.12f\n", ans * 1.0 / t / t);
  return 0;
}
