#include <bits/stdc++.h>
using namespace std;
int n, m, maxx = 0, s, minn, a, b, c, d;
char a1[21][21];
int fx[4] = {0, 0, 1, -1};
int fy[4] = {1, -1, 0, 0};
int di[21][21];
int dfs(int x, int y, int l, int r) {
  di[x][y] = min(di[x][y], s);
  for (int i = 0; i <= 3; i++) {
    if (a1[x + fx[i]][y + fy[i]] == '.') {
      a1[x][y] = '#';
      s++;
      dfs(x + fx[i], y + fy[i], l, r);
      a1[x][y] = '.';
      s--;
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a1[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a1[i][j] == '.') {
        for (int i = 1; i <= n; i++) {
          for (int j = 1; j <= m; j++) {
            di[i][j] = 210000000;
          }
        }
        dfs(i, j, i, j);
        for (int i = 1; i <= n; i++) {
          for (int j = 1; j <= m; j++) {
            if (di[i][j] != 210000000) {
              maxx = max(maxx, di[i][j]);
            }
          }
        }
      }
    }
  }
  cout << maxx;
}
