#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S_c(H);
  bool S[21][21] = {};
  for (int i = 0; i < H; i++) {
    cin >> S_c[i];
    for (int j = 0; j < W; j++) {
      if (S_c[i][j] == '.') {
        S[i][j] = true;
      } else
        S[i][j] = false;
    }
  }
  queue<pair<int, int>> q;
  bool final = false;
  int ans = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      q.push(make_pair(i, j));
      q.push(make_pair(-1, -1));
      int sum = 0;
      bool visit[21][21];
      for (int k = 0; k < 21; k++)
        for (int l = 0; l < 21; l++) visit[k][l] = false;
      while (!q.empty()) {
        int now[2] = {q.front().first, q.front().second};
        q.pop();
        if (now[0] == -1 && now[1] == -1 && !final) {
          q.push(make_pair(-1, -1));
          sum++;
          final = true;
        } else
          final = false;
        for (int k = 0; k < 4; k++) {
          if (0 <= now[0] + dy[k] && now[0] + dy[k] < H &&
              0 <= now[1] + dx[k] && now[1] + dx[k] < W &&
              !visit[now[0] + dy[k]][now[1] + dx[k]]) {
            if (S[now[0] + dy[k]][now[1] + dx[k]]) {
              q.push(make_pair(now[0] + dy[k], now[1] + dx[k]));
              visit[now[0] + dy[k]][now[1] + dx[k]] = true;
            }
          }
        }
      }
      ans = max(ans, sum);
    }
  }
  cout << ans - 1;
  return 0;
}
