using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    static int dfs(int i, int j,int ans,int W,int H,char[,]maze,int[,]d)
    {
        char[,] backup = maze;
        int type = 0;
        d[i, j] = 2;
        if (0<=i-1&&i-1<H&& backup[i - 1, j] == '.'&&d[i-1,j]==-1) {type = 1; }
        if (0 <= i + 1 && i + 1 < H && backup[i + 1, j] == '.' && d[i + 1, j] == -1) {type = 2; }
        if (0 <= j + 1 && j + 1 < W && backup[i, j+1] == '.' && d[i, j+1] == -1) {type = 3; }
        if (0 <= j - 1 && j - 1 < W && backup[i, j - 1] == '.' && d[i, j-1] == -1) {type = 4; }
        if (type == 1) { ans++; return dfs(i - 1, j, ans, W, H, backup,d); }
        else if (type == 2) { ans++; return dfs(i + 1, j, ans, W, H, backup,d); }
        else if (type == 3) { ans++; return dfs(i, j + 1, ans, W, H, backup,d); }
        else if (type == 4) { ans++; return dfs(i, j - 1, ans, W, H, backup,d); }
        else{ return ans; }
    }
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split();
        int H = int.Parse(input[0]);
        int W = int.Parse(input[1]);
        char[,] maze = new char[H, W];
        int[,] d = new int[H, W];
        for (int i =0; i < H; i++)
        {
            string temp = Console.ReadLine();
            for (int j = 0; j < W; j++)
            {
                maze[i, j] = temp[j];
                d[i, j] = -1;
            }
        }
        int max = 0;
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W; j++)
                {
                    if(maze[i, j] == '.') max=Math.Max(max,dfs(i, j, 0, W, H, maze,d));
                for (int k = 0; k < H; k++)
                {
                    for (int l = 0; l < W; l++)
                    {
                        d[k, l] = -1;
                    }
                }
            }
            }
        Console.WriteLine(max);
    }
}
