#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1011;
char field[MAXN][MAXN];
int n, m, row[MAXN], col[MAXN];
vector<pair<int, int> > vt;
long long solve(int n, int m, int row[]) {
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (row[i] == -1) continue;
    int last = 0, start = i;
    while (i <= n && row[i] != -1 && row[i] > last) last = row[i++];
    for (int f = start, end = --i; f <= end; f++)
      for (int s = f; s <= end; s++)
        ans += 2 * (f == s ? 1 : 2) * (row[f] - 1) * (m - row[s]);
  }
  for (int i = 1; i <= n; i++) {
    if (row[i] == -1) continue;
    int last = m + 1, start = i;
    while (i <= n && row[i] != -1 && row[i] < last) last = row[i++];
    for (int f = start, end = --i; f <= end; f++)
      for (int s = f; s <= end; s++)
        ans += 2 * (f == s ? 1 : 2) * (m - row[f]) * (row[s] - 1);
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  int num = n * m;
  for (int i = 1; i <= n; i++) scanf("%s", field[i] + 1);
  memset(row, -1, sizeof(row));
  memset(col, -1, sizeof(col));
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (field[i][j] == 'X') {
        row[i] = j;
        col[j] = i;
        vt.push_back(make_pair(i, j));
        num--;
      }
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans += (long long)m * m * i * (i - 1);
  for (int i = 1; i <= m; i++) ans += (long long)n * n * i * (i - 1);
  for (int i = 1; i <= n; i++)
    for (int k = 0; k < (int)vt.size(); k++)
      ans -= 2 * m * abs(i - vt[k].first);
  for (int i = 1; i <= m; i++)
    for (int k = 0; k < (int)vt.size(); k++)
      ans -= 2 * n * abs(i - vt[k].second);
  for (int i = 0; i < (int)vt.size(); i++)
    for (int j = 0; j < (int)vt.size(); j++)
      ans += abs(vt[i].first - vt[j].first) + abs(vt[i].second - vt[j].second);
  ans += solve(n, m, row);
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= m; j++) swap(field[i][j], field[j][i]);
  ans += solve(m, n, col);
  printf("%.10f\n", (double)ans / num / num);
  return 0;
}
