#include <bits/stdc++.h>
using namespace std;
int main() {
  long long H, W;
  cin >> H >> W;
  long long ar[H][W];
  char s[H][W];
  for (long long i = 0; i < H; i++) {
    for (long long j = 0; j < W; j++) cin >> s[i][j];
  }
  long long ans = 0;
  for (long long i = 0; i < H; i++) {
    for (long long j = 0; j < W; j++) {
      for (long long k = 0; k < H; k++) {
        for (long long m = 0; m < W; m++) {
          if (i != k || j != m) {
            long long a = i, b = k, c = j, d = m;
            long long ct = 0, cc = 0;
            if (s[k][m] == '.') {
              while ((a != b || c != d) && cc < 15) {
                cc++;
                if (a > b && s[a - 1][c] == '.') {
                  a--;
                  ct++;
                } else if (b > a && s[a + 1][c] == '.') {
                  a++;
                  ct++;
                } else if (c > d && s[a][c - 1] == '.') {
                  c--;
                  ct++;
                } else if (d > c && s[a][c + 1] == '.') {
                  c++;
                  ct++;
                } else if (s[a][c + 1] == '.') {
                  c++;
                  ct++;
                } else if (s[a][c - 1] == '.') {
                  c--;
                  ct++;
                } else if (s[a + 1][c] == '.') {
                  a++;
                  ct++;
                } else if (s[a - 1][c] == '.') {
                  a--;
                  ct++;
                }
              }
            }
            ans = max(ans, ct);
          }
        }
      }
    }
  }
  cout << ans << "\n";
}
