#include <bits/stdc++.h>
using namespace std;
int n, m, ans = 0;
char A[21][21];
int vis[21][21];
int bfs(pair<int, int> p, int level) {
  if (A[p.first][p.second] == '*') return 0;
  queue<pair<int, int>> q;
  q.push(p);
  vis[p.first][p.second] = level;
  while (!q.empty()) {
    pair<int, int> p_t = q.front();
    q.pop();
    int k = vis[p_t.first][p_t.second];
    if (p_t.first + 1 < n and A[p_t.first + 1][p_t.second] == '.') {
      if (vis[p_t.first + 1][p_t.second] == -1) {
        vis[p_t.first + 1][p_t.second] = k + 1;
        level = max(level, vis[p_t.first + 1][p_t.second]);
        q.push({p_t.first + 1, p_t.second});
      }
    }
    if (p_t.second + 1 < m and A[p_t.first][p_t.second + 1] == '.') {
      if (vis[p_t.first][p_t.second + 1] == -1) {
        vis[p_t.first][p_t.second + 1] = k + 1;
        level = max(level, vis[p_t.first][p_t.second + 1]);
        q.push({p_t.first, p_t.second + 1});
      }
    }
    if (p_t.first - 1 >= 0 and A[p_t.first - 1][p_t.second] == '.') {
      if (vis[p_t.first - 1][p_t.second] == -1) {
        vis[p_t.first - 1][p_t.second] = k + 1;
        level = max(level, vis[p_t.first - 1][p_t.second]);
        q.push({p_t.first - 1, p_t.second});
      }
    }
    if (p_t.second - 1 >= 0 and A[p_t.first][p_t.second - 1] == '.') {
      if (vis[p_t.first][p_t.second - 1] == -1) {
        vis[p_t.first][p_t.second - 1] = k + 1;
        level = max(level, vis[p_t.first][p_t.second - 1]);
        q.push({p_t.first, p_t.second - 1});
      }
    }
  }
  return level;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> A[i][j];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      memset(vis, -1, sizeof(vis));
      ans = max(ans, bfs({i, j}, 0));
    }
  }
  cout << ans;
}
