#include <bits/stdc++.h>
using namespace std;
struct Corr {
  long long int y;
  long long int x;
  long long int depth;
};
char vec[20][20];
queue<Corr> q;
int N, M;
vector<long long int> y_vec = {0, 0, -1, +1};
vector<long long int> x_vec = {-1, +1, 0, 0};
long long int y, x, depth;
long long int d;
bool flag = 0;
void bfs() {
  while (!q.empty()) {
    Corr now = q.front();
    q.pop();
    y = now.y, x = now.x, depth = now.depth;
    for (long long int i = 0; i < 4; ++i) {
      Corr next = {y + y_vec[i], x + x_vec[i], depth + 1};
      if (0 <= next.y && next.y <= N - 1 && 0 <= next.x && next.x <= M - 1 &&
          vec[next.y][next.x] == '.') {
        vec[next.y][next.x] = 'x';
        q.push(next);
        flag = 1;
      }
    }
    if (!flag) d = depth;
    flag = 0;
  }
  return;
}
int main() {
  int ans = 0;
  cin >> N >> M;
  char map[20][20];
  for (y = 0; y < N; y++) {
    for (x = 0; x < M; x++) {
      cin >> map[y][x];
    }
  }
  for (int s_y = 0; s_y < N; ++s_y) {
    for (int s_x = 0; s_x < M; ++s_x) {
      for (y = 0; y < N; y++) {
        for (x = 0; x < M; x++) {
          vec[y][x] = map[y][x];
        }
      }
      if (vec[s_y][s_x] == '.') {
        Corr start = {s_y, s_x, 0};
        q.emplace(start);
        bfs();
        if (d > ans) ans = d;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
