#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> s(h, vector<char>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) cin >> s[i][j];
  }
  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      vector<vector<int>> distance(h, vector<int>(w));
      vector<vector<bool>> a(h, vector<bool>(w));
      a[i][j] = true;
      queue<int> q;
      q.push(i);
      q.push(j);
      if (s[i][j] == '.') {
        while (!q.empty()) {
          int f = q.front();
          q.pop();
          int g = q.front();
          q.pop();
          cout << f << " " << g << endl;
          if (f - 1 >= 0) {
            if (!a[f - 1][g] && s[f - 1][g] == '.') {
              int c = distance[f][g] + 1;
              ans = max(ans, c);
              distance[f - 1][g] = c;
              a[f - 1][g] = true;
              q.push(f - 1);
              q.push(g);
            }
          }
          if (f + 1 <= h - 1) {
            if (!a[f + 1][g] && s[f + 1][g] == '.') {
              int d = distance[f][g] + 1;
              ans = max(ans, d);
              distance[f + 1][g] = d;
              a[f + 1][g] = true;
              q.push(f + 1);
              q.push(g);
            }
          }
          if (g - 1 >= 0) {
            if (s[f][g - 1] == '.' && !a[f][g - 1]) {
              int e = distance[f][g] + 1;
              ans = max(ans, e);
              distance[f][g - 1] = e;
              a[f][g - 1] = true;
              q.push(f);
              q.push(g - 1);
            }
          }
          if (g + 1 <= w - 1) {
            if (!a[f][g + 1] && s[f][g + 1] == '.') {
              int k = distance[f][g] + 1;
              ans = max(ans, k);
              distance[f][g + 1] = k;
              a[f][g + 1] = true;
              q.push(f);
              q.push(g + 1);
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
}
