#include <bits/stdc++.h>
using namespace std;
const int MAXN = 87;
int maze[MAXN][MAXN];
bool visit[MAXN][MAXN];
int stepx[4] = {-1, 1, 0, 0};
int stepy[4] = {0, 0, -1, 1};
char s[MAXN];
int bfs(int x, int y, int H, int W) {
  memset(visit, 0, sizeof(visit));
  int lv = 0;
  queue<pair<int, int> > qu;
  qu.push(make_pair(x, y));
  visit[x][y] = 1;
  while (!qu.empty()) {
    queue<pair<int, int> > nqu;
    while (!qu.empty()) {
      auto tmp = qu.front();
      qu.pop();
      int curx = tmp.first, cury = tmp.second;
      for (int i = 0; i < 4; i++) {
        int nx = stepx[i] + curx, ny = stepy[i] + cury;
        if (stepx[i] + curx < 0 || stepx[i] + curx == H) continue;
        if (stepy[i] + cury < 0 || stepy[i] + cury == W) continue;
        if (!maze[nx][ny]) continue;
        if (visit[nx][ny]) continue;
        visit[nx][ny] = 1;
        nqu.push(make_pair(nx, ny));
      }
    }
    qu = nqu;
    lv++;
  }
  return lv - 1;
}
int main() {
  int H, W;
  scanf("%d %d", &H, &W);
  for (int i = 0; i < H; i++) {
    scanf("%s", s);
    for (int j = 0; j < W; j++)
      if (s[j] == '.') maze[i][j] = 1;
  }
  int ans = 0;
  for (int i = 0; i < H; i++)
    for (int j = 0; j < W; j++) {
      ans = max(ans, bfs(i, j, H, W));
    }
  printf("%d\n", ans);
  return 0;
}
