#include <bits/stdc++.h>
using namespace std;
static const long long INF = 1000000;
using p = pair<int, int>;
int main() {
  int h, w;
  cin >> h, w;
  vector<vector<char>> road(h, vector<char>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      char s;
      cin >> s;
      road[i][j] = s;
    }
  }
  auto haba = [&](int sh, int sw) {
    queue<p> q;
    q.push({sh, sw});
    vector<vector<int>> score(h, vector<int>(w, 0));
    vector<vector<int>> color(h, vector<int>(w, 0));
    auto judge = [&](int gh, int gw) {
      if (0 <= gh < h) {
        if (0 <= gw < w) {
          if (road[gh][gw] == '.' and color[gh][gw] == 0) {
            return true;
          }
        }
      }
      return false;
    };
    while (!q.empty()) {
      p sp = q.front();
      color[sp.first][sp.second] = 1;
      q.pop();
      p p1, p2, p3, p4;
      p1 = {sp.first - 1, sp.second};
      p2 = {sp.first + 1, sp.second};
      p3 = {sp.first, sp.second - 1};
      p4 = {sp.first, sp.second + 1};
      if (judge(p1.first, p1.second)) {
        q.push(p1);
        score[p1.first][p1.second] = score[sp.first][sp.second] + 1;
        color[p1.first][p1.second] = 1;
      }
      if (judge(p2.first, p2.second)) {
        q.push(p2);
        score[p2.first][p2.second] = score[sp.first][sp.second] + 1;
        color[p2.first][p2.second] = 1;
      }
      if (judge(p3.first, p3.second)) {
        q.push(p3);
        score[p3.first][p3.second] = score[sp.first][sp.second] + 1;
        color[p3.first][p3.second] = 1;
      }
      if (judge(p4.first, p4.second)) {
        q.push(p4);
        score[p4.first][p4.second] = score[sp.first][sp.second] + 1;
        color[p4.first][p4.second] = 1;
      }
    }
    int mx = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        mx = max(mx, score[i][j]);
      }
    }
    return mx;
  };
  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (road[i][j] == '.') {
        cout << i << j << endl;
        int m = haba(i, j);
        ans = max(ans, m);
      }
    }
  }
  cout << ans << endl;
}
