#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using edge = struct {
  int to;
  ll cost;
};
long long combination[10001][10001];
char s[22][22];
bool visit[22][22];
int dis[22][22];
queue<pair<int, int>> q;
int h, w;
int ans = 0;
int cost;
void minit() {
  for (int i = 0; i <= h + 1; i++) {
    for (int j = 0; j <= w + 1; j++) {
      if (i == 0 || i == h + 1 || j == 0 || j == w + 1)
        visit[i][j] = true;
      else
        visit[i][j] = false;
      dis[i][j] = 0;
    }
  }
}
void bfs() {
  if (q.empty()) return;
  auto now = q.front();
  q.pop();
  int i = now.first, j = now.second;
  cout << i << " " << j << " " << cost << "\n";
  visit[i][j] = true;
  ans = max(ans, cost);
  if (!visit[i + 1][j] && s[i + 1][j] == '.') q.push(make_pair(i + 1, j));
  if (!visit[i - 1][j] && s[i - 1][j] == '.') q.push(make_pair(i - 1, j));
  if (!visit[i][j + 1] && s[i][j + 1] == '.') q.push(make_pair(i, j + 1));
  if (!visit[i][j - 1] && s[i][j - 1] == '.') q.push(make_pair(i, j - 1));
  cost++;
  bfs();
}
void solve() {
  clock_t start = clock();
  cin >> h >> w;
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) cin >> s[i][j];
  }
  for (int i = 1; i <= h; i++) {
    clock_t rap = clock();
    if ((double)(rap - start) >= 1600.0) {
      cout << 400 - 10 * 19 << "\n";
      return;
    }
    for (int j = 1; j <= w; j++) {
      if (s[i][j] == '.') {
        minit();
        queue<pair<int, int>> empty;
        swap(q, empty);
        q.push(make_pair(i, j));
        while (true) {
          if (q.empty()) break;
          auto now = q.front();
          q.pop();
          int I = now.first, J = now.second;
          ans = max(ans, dis[I][J]);
          visit[I][J] = true;
          if (!visit[I + 1][J] && s[I + 1][J] == '.')
            q.push(make_pair(I + 1, J));
          dis[I + 1][J] = dis[I][J] + 1;
          if (!visit[I - 1][J] && s[I - 1][J] == '.')
            q.push(make_pair(I - 1, J));
          dis[I - 1][J] = dis[I][J] + 1;
          if (!visit[I][J + 1] && s[I][J + 1] == '.')
            q.push(make_pair(I, J + 1));
          dis[I][J + 1] = dis[I][J] + 1;
          if (!visit[I][J - 1] && s[I][J - 1] == '.')
            q.push(make_pair(I, J - 1));
          dis[I][J - 1] = dis[I][J] + 1;
        }
      }
    }
  }
  cout << ans << "\n";
}
int main() {
  solve();
  return 0;
}
