#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
long long llpow(T x, T n) {
  long long ans = 1;
  while (n--) {
    ans *= x;
  }
  return ans;
}
long long INF = 1LL << 60;
int n;
int ch(int x) {
  if (x == 0)
    return -1;
  else {
    return x;
  }
}
bool visited[20][20];
char s[20][20];
int ans = 0;
int h, w;
void seek(int temp, int starth, int startw) {
  for (int jouge = 0; jouge < 2; jouge++) {
    for (int sayuu = 0; sayuu < 2; sayuu) {
      if (ch(jouge) + starth >= 0 && ch(jouge) + starth < h &&
          ch(sayuu) + startw < w >= 0 && ch(sayuu) + startw < w &&
          s[ch(jouge) + starth][ch(sayuu) + startw] == '.' &&
          visited[ch(jouge) + starth][ch(sayuu) + startw] == false) {
        temp++;
        chmax(ans, temp);
        visited[ch(jouge) + starth][ch(sayuu) + startw] = true;
        seek(temp, ch(jouge) + starth, ch(sayuu) + startw);
      }
    }
  }
}
int main() {
  cin >> h >> w;
  for (long long i = 0; i < (long long)h; i++)
    for (long long j = 0; j < (long long)w; j++) cin >> s[i][j];
  for (int starth = 0; starth < h; starth++) {
    for (int startw = 0; startw < w; startw++) {
      int temp = 0;
      if (s[starth][startw] == '#')
        continue;
      else {
        for (long long i = 0; i < (long long)20; i++)
          for (long long j = 0; j < (long long)20; j++) {
            visited[i][j] = false;
          }
        seek(temp, starth, startw);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
