#include <bits/stdc++.h>
void swap(long long* a, long long* b) {
  long long tmp = *a;
  *a = *b;
  *b = tmp;
}
long long lpow(long long a, long long n) {
  long long ans = pow(a, n) * 10;
  if (ans % 10 < 5) return ans / 10;
  return ans / 10 + 1;
}
long long dup(long long a, long long d) {
  if (a % d == 0)
    return a / d;
  else
    return a / d + 1;
}
long long GCD(long long a, long long b) {
  long long c = 1, tmp = ((a) < (b) ? (b) : (a));
  b = ((a) < (b) ? (a) : (b));
  a = tmp;
  while (c != 0) {
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}
long long LCM(long long a, long long b) { return a * b / GCD(a, b); }
int lcmp(const void* a, const void* b) {
  if (*(long long*)a > *(long long*)b) return 1;
  if (*(long long*)a < *(long long*)b) return -1;
  return 0;
}
int ccmp(const void* a, const void* b) { return *(char*)a - *(char*)b; }
int scmp(const void* a, const void* b) {
  return strcmp(*(char**)a, *(char**)b);
}
long long mod(long long a, long long m) {
  if (a < 0)
    return a % m + m;
  else
    return a % m;
}
long long DIV(long long a, long long d) {
  long long m = 1000000007, x = 1, y = 0, k;
  while (m) {
    k = d / m;
    d -= k * m;
    swap(&m, &d);
    x -= k * y;
    swap(&x, &y);
  }
  return mod(a * mod(x, 1000000007), 1000000007);
}
long long FAC(long long a) {
  long long i, ans = 1;
  for (i = 1; i < a + 1; i++) {
    ans *= i;
    if (1000000007 > 0 && ans > 1000000007) ans %= 1000000007;
  }
  return ans;
}
long long POW(long long a, long long n) {
  long long ans = 1;
  while (n > 0) {
    if (n & 1) ans = ans * a % 1000000007;
    a = a * a % 1000000007;
    n >>= 1;
  }
  return ans;
}
long long dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}, H, W;
char S[20][21];
long long co[500][500] = {0};
void bfs() {
  long long I, J, i, j, k, s1, s2, nx, ny;
  for (I = 0; I < H; I++)
    for (J = 0; J < W; J++)
      if (S[I][J] == '.') {
        long long n = 0, m = 0, A[500] = {0}, flag[500] = {0};
        i = I, j = J, s1 = i * W + j;
        flag[s1] = 1;
        while (1) {
          for (k = 0; k < 4; k++) {
            nx = i + dx[k], ny = j + dy[k], s2 = nx * W + ny;
            if (nx >= 0 && nx < H && ny >= 0 && ny < W)
              if (S[nx][ny] == '.')
                if (flag[s2] == 0) {
                  flag[s2] = 1, A[n++] = s2, co[s1][s2] = co[s1][i * W + j] + 1;
                  printf("%lld %lld %lld\n", co[s1][s2], s1, s2);
                }
          }
          if (m == n) break;
          i = A[m] / W, j = A[m++] % W;
        }
      }
}
int main() {
  long long i, j, ans = 0;
  scanf("%lld%lld", &H, &W);
  for (i = 0; i < H; i++) scanf("%s", S[i]);
  bfs();
  for (i = 0; i < H * W; i++)
    for (j = i; j < H * W; j++) ans = ((ans) < (co[i][j]) ? (co[i][j]) : (ans));
  printf("%lld\n", ans);
  return 0;
}
