#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
  long long g = gcd(a, b);
  return a / g * b;
}
long long factorial(long long n) {
  long long t = 1;
  for (long long(i) = 1; (i) <= (n); ++(i)) t *= i;
  return t;
}
long long combinations(long long n, long long k) {
  long long r = 1;
  for (long long(i) = 1; (i) <= (k); ++(i)) r = r * n-- / i;
  return r;
}
int cnt(pair<int, int> stert, bool g[22][22]) {
  int x[] = {1, -1, 0, 0}, y[] = {0, 0, 1, -1};
  int ans = 0;
  queue<pair<int, int>> next, now, empty;
  next.push(stert);
  do {
    ++ans;
    now = next;
    next = empty;
    while (!now.empty()) {
      g[now.front().first][now.front().second] = false;
      for (long long(i) = 0; (i) < (4); ++(i)) {
        if (g[now.front().first + x[i]][now.front().second + y[i]]) {
          next.push(
              make_pair(now.front().first + x[i], now.front().second + y[i]));
          g[now.front().first + x[i]][now.front().second + y[i]] = false;
        }
      }
      now.pop();
    }
  } while (!next.empty());
  return ans - 1;
}
int main() {
  int h, w;
  cin >> h >> w;
  bool G[22][22], G2[22][22];
  for (long long(i) = 0; (i) < (22); ++(i))
    for (long long(j) = 0; (j) < (22); ++(j)) G[i][j] = false;
  for (long long(i) = 0; (i) < (h + 2); ++(i)) {
    for (long long(j) = 0; (j) < (w + 2); ++(j)) {
      if (i == 0 || i == h + 1 || j == 0 || j == w + 1)
        G[i][j] = false;
      else {
        char a;
        cin >> a;
        if (a == '#')
          G[i][j] = false;
        else
          G[i][j] = true;
      }
    }
  }
  int ans = 0;
  for (long long(i) = 1; (i) <= (h); ++(i)) {
    for (long long(j) = 1; (j) <= (w); ++(j)) {
      for (long long(i) = 0; (i) < (22); ++(i))
        for (long long(j) = 0; (j) < (22); ++(j)) G2[i][j] = G[i][j];
      ans = max(ans, cnt(make_pair(i, j), G2));
    }
  }
  cout << (ans) << endl;
  ;
  return 0;
}
