#include <bits/stdc++.h>
using namespace std;
char g[22][22];
int dis[22 * 22][22 * 22];
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
int n, m;
int get_id(int i, int j) { return i * m + j; }
void bfs(int i, int j) {
  int u = get_id(i, j);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      dis[u][get_id(i, j)] = INT_MAX;
    }
  }
  if (g[i][j] == '#') return;
  queue<int> q;
  q.push(u);
  dis[u][u] = 0;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    int x = v / m, y = v % m;
    cout << x << " " << y << endl;
    for (int i = 0; i < 4; i++) {
      int nx = x + dx[i], ny = y + dy[i];
      int nv = get_id(nx, ny);
      if (nx < 0 || nx >= n || ny < 0 || ny >= m || g[nx][ny] == '#' ||
          nv < 0 || nv >= n * m || dis[u][nv] != INT_MAX)
        continue;
      q.push(nv);
      dis[u][nv] = dis[u][v] + 1;
    }
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> g[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      bfs(i, j);
    }
  }
  int ans = 0;
  for (int i = 0; i < n * m; i++) {
    for (int j = 0; j < n * m; j++) {
      if (dis[i][j] != INT_MAX) ans = max(ans, dis[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}
