#include <bits/stdc++.h>
using namespace std;
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void neg() { cout << -1 << endl; }
void unhap() { cout << ":(" << endl; }
int bfs(int h, int w, vector<vector<char>> &grid, int i, int j) {
  vector<vector<int>> bfsvis(h, vector<int>(w, 0));
  queue<vector<int>> bfstask;
  bfstask.push({i, j});
  int cnt = 0;
  while (bfstask.size() > 0) {
    int sz = bfstask.size();
    for (int i = 0; i < sz; i++) {
      int x = bfstask.front().at(0), y = bfstask.front().at(1);
      if (x + 1 < h && bfsvis.at(x + 1).at(y) == 0 &&
          grid.at(x + 1).at(y) == '.')
        bfstask.push({x + 1, y});
      if (x - 1 >= 0 && bfsvis.at(x - 1).at(y) == 0 &&
          grid.at(x - 1).at(y) == '.')
        bfstask.push({x - 1, y});
      if (y + 1 < w && bfsvis.at(x).at(y + 1) == 0 &&
          grid.at(x).at(y + 1) == '.')
        bfstask.push({x, y + 1});
      if (y - 1 >= 0 && bfsvis.at(x).at(y - 1) == 0 &&
          grid.at(x).at(y - 1) == '.')
        bfstask.push({x, y - 1});
      bfsvis.at(x).at(y) = 1;
      bfstask.pop();
    }
    cnt++;
  }
  return cnt;
}
int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> grid(h, vector<char>(w));
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++) cin >> grid.at(i).at(j);
  priority_queue<int> ans;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (grid.at(i).at(j) == '#') continue;
      ans.push(bfs(h, w, grid, i, j));
    }
  }
  cout << ans.top() - 1 << endl;
}
