#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = 1e16;
const long long MAX_N = 100010;
const long long dx[4] = {1, 0, -1, 0};
const long long dy[4] = {0, 1, 0, -1};
int main() {
  long long h, w, n;
  cin >> h >> w >> n;
  vector<string> board(h);
  for (long long i = 0; i < h; i++) {
    cin >> board[i];
  }
  long long ans = 0;
  for (long long sx = 0; sx < h; sx++) {
    for (long long sy = 0; sy < w; sy++) {
      if (board[sx][sy] == '#') {
        continue;
      }
      vector<vector<long long>> matrix(h, vector<long long>(w, -1));
      queue<pair<long long, long long>> next;
      next.push(make_pair(sx, sy));
      matrix[sx][sy] = 0;
      while (!next.empty()) {
        long long x = next.front().first;
        long long y = next.front().second;
        for (long long i = 0; i < 4; i++) {
          long long nx = x + dx[i];
          long long ny = y + dy[i];
          if (nx < 0 || h <= nx || ny < 0 || w <= ny || 0 <= matrix[nx][ny]) {
            continue;
          }
          if (board[nx][ny] == '#') {
            continue;
          }
          matrix[nx][ny] = matrix[x][y] + 1;
          next.push(make_pair(nx, ny));
        }
        next.pop();
      }
      long long now = 0;
      for (long long i = 0; i < h; i++) {
        for (long long j = 0; j < w; j++) {
          now = max(now, matrix[i][j]);
        }
      }
      ans = max(ans, now);
    }
  }
  cout << ans << endl;
  return 0;
}
