#include <bits/stdc++.h>
using namespace std;
int func(int x, int y, int h, int w, string *s) {
  if (s[x][y] == '#') return 0;
  bool diff = true;
  int cnt = -1;
  s[x][y] = 'o';
  while (diff) {
    diff = false;
    cnt++;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (s[i][j] == 'o') {
          if (i - 1 >= 0)
            if (s[i - 1][j] == '.') {
              s[i - 1][j] = 'o';
              diff = true;
            }
          if (i + 1 <= h - 1)
            if (s[i + 1][j] == '.') {
              s[i + 1][j] = 'o';
              diff = true;
            }
          if (j - 1 >= 0)
            if (s[i][j - 1] == '.') {
              s[i][j - 1] = 'o';
              diff = true;
            }
          if (j + 1 <= w - 1)
            if (s[i][j + 1] == '.') {
              s[i][j + 1] = 'o';
              diff = true;
            }
        }
      }
    }
  }
  return cnt;
}
int main() {
  int h, w;
  char c;
  string str;
  cin >> h >> w;
  string s[h];
  for (int i = 0; i < h; i++) {
    cin >> str;
    s[i] = str;
  }
  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int longest = func(i, j, h, w, s);
      cout << longest << endl;
      ans = max(ans, longest);
    }
  }
  cout << ans << endl;
}
