#include <bits/stdc++.h>
using namespace std;
double ans;
int row[1005], col[1005];
char str[1005];
void work(int *arr, int n, int m) {
  int sum = 0;
  for (int i = 0; i < n; i++) {
    if (-1 == arr[i]) continue;
    sum += arr[i];
    ans += sum * (m - arr[i] - 1);
    if (arr[i + 1] < arr[i]) sum = 0;
  }
  for (int i = 0; i < n; i++) {
    if (-1 == arr[i]) continue;
    ans += sum * arr[i];
    sum += m - arr[i] - 1;
    if (arr[i + 1] == -1 || arr[i + 1] > arr[i]) sum = 0;
  }
}
int main() {
  memset(row, -1, sizeof(row));
  memset(col, -1, sizeof(col));
  int n, m, cnt = 0;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%s", str);
    for (int j = 0; j < m; j++) {
      if (str[j] == 'X') {
        row[i] = j;
        col[j] = i;
        cnt++;
      }
    }
  }
  work(row, n, m);
  work(col, m, n);
  ans *= 2;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= i; j++)
      ans += (m - (row[i] != -1)) * (m - (row[j] != -1)) * (i - j);
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j <= i; j++)
      ans += (n - (col[i] != -1)) * (n - (col[j] != -1)) * (i - j);
  }
  ans = ans * 2 / (n * m - cnt) / (n * m - cnt);
  printf("%.15lf\n", ans);
  return 0;
}
