#include <bits/stdc++.h>
using namespace std;
int h, w, sx, sy, nx, ny, dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1},
                          ch[20][20], MAX, ans;
string dp[20];
queue<pair<int, int> > que;
int main(void) {
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    cin >> dp[i];
    for (int j = 0; j < w; j++) {
      for (int i = 0; i < 20; i++) {
        for (int j = 0; j < 20; j++) {
          ch[i][j] = 0;
        }
      }
      if (dp[i][j] == '.') {
        sx = i;
        sy = j;
        cout << sx << " " << sy << endl;
        que.push({sx, sy});
        ch[sx][sy] = 1;
        while (que.size()) {
          auto q = que.front();
          que.pop();
          for (int i = 0; i < 4; i++) {
            nx = q.first + dx[i];
            ny = q.second + dy[i];
            if (0 <= nx && nx < h && 0 <= ny && ny < w && dp[nx][ny] == '.') {
              if (ch[nx][ny] == 0) {
                ch[nx][ny] = ch[q.first][q.second] + 1;
                que.push({nx, ny});
              }
            }
          }
        }
        for (int i = 0; i < h; i++) {
          for (int j = 0; j < w; j++) {
            if (ch[i][j] > MAX) {
              MAX = ch[i][j];
              sx = i;
              sy = j;
            }
          }
        }
        ans = max(ans, MAX);
      }
    }
  }
  cout << MAX - 1 << endl;
}
