#include <bits/stdc++.h>
using namespace std;
template <typename T>
T powint(const T& x, const T& y) {
  T ret = 1;
  for (int i = 0; i < y; ++i) ret *= x;
  return ret;
}
int H, W;
vector<string> S;
void move(int y, int x, int steps, vector<vector<int> >& count) {
  if (0 <= x && x < W && 0 <= y && y < H && S[y][x] != '#') {
    if (steps < count[y][x] || count[y][x] == -1) {
      count[y][x] = steps++;
      cout << x << " " << y << " " << count[y][x] << endl;
      move(y + 1, x, steps, count);
      move(y - 1, x, steps, count);
      move(y, x + 1, steps, count);
      move(y, x - 1, steps, count);
    }
  }
}
int main() {
  cin >> H >> W;
  S.resize(H);
  for (int i = 0; i < H; ++i) cin >> S[i];
  int ans = 0;
  int x, y;
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      vector<vector<int> > count(H);
      for (int k = 0; k < H; ++k) count[k].resize(W, -1);
      x = j;
      y = i;
      if (S[y][x] == '#') continue;
      move(y, x, 0, count);
      for (int k = 0; k < H; ++k) {
        for (int l = 0; l < W; ++l) {
          ans = max(ans, count[k][l]);
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
