#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  int ans = 0;
  cin >> h >> w;
  vector<string> s(h);
  for (int i = 0; i < h; ++i) {
    cin >> s[i];
  }
  for (int si = 0; si < h; ++si)
    for (int sj = 0; sj < w; ++sj) {
      if (s[si][sj] == '#') continue;
      vector<vector<int>> dist(h, vector<int>(w, INF));
      queue<pair<int, int>> q;
      auto update = [&](int i, int j, int x) {
        if (dist[i][j] != INF) return;
        dist[i][j] = x;
        q.push(pair<int, int>(i, j));
      };
      update(si, sj, 0);
      while (!q.empty()) {
        int i = q.front().first;
        int j = q.front().second;
        q.pop();
        for (int dir = 0; dir < 4; ++dir) {
          int ni = i + di[dir];
          int nj = j + dj[dir];
          if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
          update(ni, nj, dist[i][j] + 1);
        }
      }
      for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j) {
          if (dist[i][j] == INF) continue;
          ans += max(ans, dist[i][j]);
        }
    }
  cout << ans << endl;
  cout << endl;
  return 0;
}
