using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush=
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var H = cin.ReadInt;
			var W = cin.ReadInt;
			var S = new bool[H, W];
			var G = new Graph<int>(H*W);
			for(int i = 0; i<H; i++) {
				var line = cin.ReadLine;
				for(int j = 0; j<W; j++) {
					S[i, j]=line[j]=='.'; 
				}
			}
			for(int i = 0; i<H-1; i++) {
				for(int j = 0; j<W; j++) {
					var point = i*W+j;
					if(S[i, j]&&S[i+1, j]) {
						G.AddEdge(point, point+W, 1);
						G.AddEdge(point+W, point, 1);
					}
				}
			}
			for(int i = 0; i<H; i++) {
				for(int j = 0; j<W-1; j++) {
					var point = i*W+j;
					if(S[i, j]&&S[i, j+1]) {
						G.AddEdge(point, point+1, 1);
						G.AddEdge(point+1, point, 1);
					}
				}
			}
			var Res = 0;
			for(int i = 0; i<H; i++) {
				for(int j = 0; j<W; j++) {
					if(!S[i, j]) continue;
					var point = i*W+j;
					var dist = new int[H* W];
					int tmp = 0;
					G.PointBFS(point, k => { dist[k]=tmp; }, k => { tmp++; });
					var count = dist.Max();
					if(Res<count) Res=count;
				}
			}
			Console.WriteLine(Res);
		}
	}
	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
		public static void MergeSort<T>(this T[] A, bool desending) where T : IComparable<T> {
			if(desending)
				MergeSort(A, Comparer<T>.Create((x, y) => y.CompareTo(x)));
			else
				MergeSort(A, Comparer<T>.Create((x, y) => x.CompareTo(y)));
		}
		public static void MergeSort<T>(T[] A, IComparer<T> comparer) where T : IComparable<T> {
			MergeSort1(0, A.Length, A, comparer);
		}
		private static void Merge<T>(int left, int mid, int right, T[] A, IComparer<T> comparer)
			where T : IComparable<T> {
			var nl = mid-left;
			var nr = right-mid;
			var L = new T[nl];
			var R = new T[nr];
			for(int i = 0; i<nl; i++)
				L[i]=A[i+left];
			for(int i = 0; i<nr; i++)
				R[i]=A[i+mid];
			int il = 0, ir = 0;
			for(int k = left; k<right; k++) {
				if(comparer.Compare(L[il], R[ir])<=0) {
					A[k]=L[il++];
					if(il==nl) {
						k++;
						for(; ir<nr;)
							A[k++]=R[ir++];
						break;
					}
				} else {
					A[k]=R[ir++];
					if(ir==nr) {
						k++;
						for(; il<nl;)
							A[k++]=L[il++];
						break;
					}
				}
			}
		}
		private static void MergeSort1<T>(int left, int right, T[] A, IComparer<T> comparer)
		where T : IComparable<T> {
			if(left+1<right) {
				var mid = (left+right)/2;
				MergeSort1(left, mid, A, comparer);
				MergeSort1(mid, right, A, comparer);
				Merge(left, mid, right, A, comparer);
			}
		}
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator=separator;
			this._stream=stream;
			inputStream=new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count!=0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i<tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i<N; ++i)
				ret[i]=Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i<N; ++i) ret[i]=ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i<N; ++i) ret[i]=ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i<N; ++i) ret[i]=ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek()==-1; }
		}
	}
	class Graph<T> {
		public readonly int N;
		public T[] Nodes { get; }
		protected List<int>[] Nexts { get; }
		protected Dictionary<int, T>[] Edges { get; set; }
		public Graph(int _N) {
			N=_N;
			Nodes=new T[_N];
			Nexts=new List<int>[_N];
			Edges=new Dictionary<int, T>[_N];
			for(int i = 0; i<_N; i++) {
				Nexts[i]=new List<int>();
				Edges[i]=new Dictionary<int, T>();
			}
		}
		public void Update(int i, T value) {
			Nodes[i]=value;
		}
		public void AddEdge(int from, int to, T value) {
			Edges[from].Add(to, value);
			Nexts[from].Add(to);
		}
		private void PointDFS(int from, Action<int> onEnter, Action<int> onLeave) {
			var S = new Stack<int>();
			S.Push(from);
			var entered = new bool[N];
			var departed = new bool[N];//dep<=ent
			var childCount = new int[N];
			while(S.Any()) {
				var v = S.Peek();
				if(!entered[v]) {
					onEnter?.Invoke(v);
					entered[v]=true;
				}
				for(int i = childCount[v]; i<Nexts[v].Count; i++) {
					if(!entered[Nexts[v][i]]) {
						S.Push(Nexts[v][i]);
						childCount[v]=i+1;
						goto NextLoop;
					}
				}
				S.Pop();
				childCount[v]=Nexts[v].Count;
				if(!departed[v]) {
					onLeave?.Invoke(v);
					departed[v]=true;
				}
			NextLoop:;
			}
		}
		public void PointBFS(int from, Action<int> onEnter, Action<int> onLeave) {
			var Q = new Queue<int>();
			Q.Enqueue(from);
			var entered = new bool[N];
			var departed = new bool[N];
			while(Q.Any()) {
				var v = Q.Dequeue();
				if(!entered[v]) {
					onEnter?.Invoke(v);
					entered[v]=true;
				}
				foreach(var w in Nexts[v]) {
					if(!entered[w]) {
						Q.Enqueue(w);
					}
				}
				if(!departed[v]) {
					onLeave?.Invoke(v);
					departed[v]=true;
				}
			}
		}
	}
}