#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long path;
string arr[100];
long long hlp[30][30] = {0};
long long findPath(int i, int j) {
  if (i + 1 < n && i + 1 >= 0 && arr[i + 1][j] == '.' && hlp[i + 1][j] == 0) {
    hlp[i + 1][j] = 1;
    path++;
    findPath(i + 1, j);
  }
  if (i - 1 >= 0 && i - 1 < n && arr[i - 1][j] == '.' && hlp[i - 1][j] == 0) {
    hlp[i - 1][j] = 1;
    path++;
    findPath(i - 1, j);
  }
  if (j + 1 < m && j + 1 >= 0 && arr[i][j + 1] == '.' && hlp[i][j + 1] == 0) {
    hlp[i][j + 1] = 1;
    path++;
    findPath(i, j + 1);
  }
  if (j - 1 >= 0 && j - 1 < m && arr[i][j - 1] == '.' && hlp[i][j - 1] == 0) {
    hlp[i][j - 1] = 1;
    path++;
    findPath(i, j - 1);
  }
  return path;
}
void reset() {
  path = 0;
  for (int i = 0; i < 30; ++i) {
    for (int j = 0; j < 30; ++j) {
      hlp[i][j] = 0;
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  string ch;
  for (int i = 0; i < n; ++i) {
    cin >> ch;
    arr[i] = ch;
  }
  long long mx = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      reset();
      path = findPath(i, j);
      if (mx < path) {
        mx = path;
      }
    }
  }
  cout << mx - 1;
  return 0;
}
