#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
int H, W;
int cnt = 0;
int maxcnt = 0;
vector<vector<char>> c(20, vector<char>(20));
vector<vector<bool>> r(20, vector<bool>(20, false));
void serch(int x, int y, int gx, int gy) {
  if (x < 0 || H <= x || y < 0 || W <= y || c.at(x).at(y) == '#') return;
  if (r.at(x).at(y) == true) return;
  if (r.at(gx).at(gy) == true) return;
  r.at(x).at(y) = true;
  cnt++;
  serch(x + 1, y, gx, gy);
  serch(x - 1, y, gx, gy);
  serch(x, y + 1, gx, gy);
  serch(x, y - 1, gx, gy);
}
void serchfirst(int x, int y, int gx, int gy) {
  r.at(x).at(y) = true;
  serch(x + 1, y, gx, gy);
  r.at(gx).at(gy) = false;
  maxcnt = max(maxcnt, cnt);
  cnt = 0;
  serch(x - 1, y, gx, gy);
  r.at(gx).at(gy) = false;
  maxcnt = max(maxcnt, cnt);
  cnt = 0;
  serch(x, y + 1, gx, gy);
  r.at(gx).at(gy) = false;
  maxcnt = max(maxcnt, cnt);
  cnt = 0;
  serch(x, y - 1, gx, gy);
  r.at(gx).at(gy) = false;
  maxcnt = max(maxcnt, cnt);
  cnt = 0;
}
int main() {
  cin >> H >> W;
  char a;
  for (int i = 0; i < (int)(H); i++) {
    for (int j = 0; j < (int)(W); j++) {
      cin >> a;
      c.at(i).at(j) = a;
    }
  }
  int flag = 0;
  int mojiflag = 0;
  int ans = 0;
  for (int i = 0; i < (int)(H); i++) {
    for (int j = 0; j < (int)(W); j++) {
      for (int k = 0; k < (int)(H); k++) {
        for (int m = 0; m < (int)(W); m++) {
          if (c.at(i).at(j) == '.' && c.at(k).at(m) == '.') {
            serchfirst(i, j, k, m);
            if (ans < maxcnt) {
            }
            ans = max(ans, maxcnt);
            cnt = 0;
            maxcnt = 0;
          }
          for (int a = 0; a < (int)(20); a++) {
            for (int b = 0; b < (int)(20); b++) {
              r.at(a).at(b) = false;
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
}
