#include <bits/stdc++.h>
using namespace std;
vector<string> field;
int h, w, sumNum, ans;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
bool seen[23][23];
void dfs(int tmph, int tmpw) {
  seen[tmph][tmpw] = true;
  for (int dir = 0; dir < 4; dir++) {
    int newh = tmph + dx[dir];
    int neww = tmpw + dy[dir];
    if (newh < 0 || newh >= h || neww < 0 || neww >= w) continue;
    if (field[newh][neww] == '#') continue;
    if (seen[newh][neww]) continue;
    sumNum++;
    dfs(newh, neww);
  }
}
void newseen() {
  for (int i = 0; i < 23; i++) {
    for (int j = 0; j < w; j++) {
      seen[i][j] = false;
    }
  }
}
int main() {
  cin >> h >> w;
  field.resize(h);
  ans = 0;
  for (int i = 0; i < h; i++) {
    cin >> field[i];
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (field[i][j] == '.') {
        sumNum = 0;
        newseen();
        dfs(i, j);
      }
    }
    ans = max(ans, sumNum);
  }
  cout << ans << endl;
  return 0;
}
