using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        string[] reader = ReadLine().Split(' ');
        int tate = int.Parse(reader[0]);
        int yoko = int.Parse(reader[1]);
        int count = 0;
        char[,] maps = new char[tate+2,yoko+2];
        for(int i=1;i<tate+1;i++){
            string zu = ReadLine();
            for(int j=1;j<yoko+1;j++){
                maps[i,j] = zu[j-1];
            }
        }
        for(int i=1;i<tate+1;i++){
            for(int j=1;j<yoko+1;j++){
                int[,] map = new int[tate+2,yoko+2];
                for(int k=0;k<tate+2;k++){
                    for(int l=0;l<yoko+2;l++){
                        map[k,l] = 99999999;
                    }
                }
                map[i,j] = 0;
                
                for(int o=0;o<100;o++){
                    
                for(int k=1;k<tate+1;k++){
                    for(int l=1;l<yoko+1;l++){
                        if(maps[k,l] == '#'){
                            continue;
                        }
                        if(maps[k-1,l] == '.'){
                            map[k,l] = Min(map[k,l],map[k-1,l]+1);
                        }
                        if(maps[k,l-1] == '.'){
                            map[k,l] = Min(map[k,l],map[k,l-1]+1);
                        }
                        if(maps[k+1,l] == '.'){
                            map[k,l] = Min(map[k,l],map[k+1,l]+1);
                        }
                        if(maps[k,l+1] == '.'){
                            map[k,l] = Min(map[k,l],map[k,l+1]+1);
                        }
                        if(map[k,l] < 999999 && maps[k,l] == '.'){
                            count = Max(count,map[k,l]);
                        }
                    }
                }
                }
            }
        }
        WriteLine(count);
    }
}