#include <bits/stdc++.h>
using namespace std;
int ans;
int H, W;
bool is_valid_move(vector<string> &board, vector<vector<bool>> &checked, int x,
                   int y) {
  if (x <= -1 || x >= W || y <= -1 || y >= H) {
    return false;
  }
  if (board.at(y).at(x) == '#') {
    return false;
  }
  if (checked.at(y).at(x)) {
    return false;
  }
  return true;
}
int reachable(vector<string> &board, vector<vector<bool>> &checked, int sx,
              int sy, int gx, int gy) {
  int x;
  int y;
  x = sx;
  y = sy;
  if (x == gx && y == gy) {
    return 0;
  }
  checked.at(y).at(x) = true;
  if (is_valid_move(board, checked, x, y - 1)) {
    ans++;
    x = x;
    y = y - 1;
  }
  if (is_valid_move(board, checked, x + 1, y)) {
    ans++;
    x++;
  }
  if (is_valid_move(board, checked, x, y + 1)) {
    ans++;
    y++;
  }
  if (is_valid_move(board, checked, x - 1, y)) {
    ans++;
    x--;
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (checked.at(j).at(i) == true) {
        return ans;
      }
    }
  }
}
int main() {
  cin >> H >> W;
  vector<string> board(W);
  for (int i = 0; i < H; i++) {
    cin >> board.at(i);
  }
  vector<vector<bool>> checked(H, vector<bool>(W, false));
  int A = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      for (int k = i; k < H; k++) {
        for (int l = 0; l < W; l++) {
          int a = reachable(board, checked, i, j, k, l);
          A = max(A, a);
        }
      }
    }
  }
  cout << A << endl;
}
