#include <bits/stdc++.h>
using namespace std;
char maze[20][20];
vector<int> g[400];
int h, w;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, -1, 0, 1};
int gr[400][400];
int main(int argc, char const *argv[]) {
  scanf("%d %d", &h, &w);
  for (int i = 0; i < 400; ++i) {
    for (int j = 0; j < 400; ++j) {
      gr[i][j] = 400;
    }
  }
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> maze[i][j];
    }
  }
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (maze[i][j] == '#') continue;
      int num = i * w + j;
      for (int k = 0; k < 4; ++k) {
        int nx = i + dx[k];
        int ny = j + dy[k];
        if (nx >= 0 and nx < h and ny >= 0 and ny < w) {
          if (maze[nx][ny] == '.') {
            gr[num][nx * w + ny] = 1;
          }
        }
      }
    }
  }
  for (int k = 0; k < h * w; k++) {
    for (int i = 0; i < h * w; i++) {
      for (int j = 0; j < h * w; j++)
        gr[i][j] = min(gr[i][j], gr[i][k] + gr[k][j]);
    }
  }
  int ans = 0;
  for (int i = 0; i < h * w; ++i) {
    for (int j = 0; j < h * w; ++j) {
      if (i == j or gr[i][j] >= 200)
        continue;
      else
        ans = max(ans, gr[i][j]);
      if (ans == 2) cout << i << " " << j << endl;
    }
  }
  cout << ans << endl;
  return 0;
}
