Oh no, while you managed to try to find the Forge of Creation, Aggregor obviously beats you to it, having the Map of Infinity. Well, now Aggregor is the ultimate ruler of the entire universe and there is much suffering and sadness in all galaxies.

Suddenly, Professor Paradox pops up in your face and stares at you, offering you a way to repair the damage that you have done. He snaps his finger and you are teleported into this weird physics-ish place.

You see right in front of you a screen of blue and red dots. Red dots are represented by a '#' and blue dots are represented by a '.'. Mr. Paradox explains that if you connect two blue dots with an imaginary “rope”, the length of that “rope” will be the amount of time you can travel back in time to save the day.

However, the rope can only go through blue dots and cannot touch the red dots. The rope need not be in a straight line, but it has to go through each grid either horizontally or vertically (you cannot move diagonally). Also, no two blue dots can be connected by a rope in more than one way.

The first line of input contains two integers C and R (3 ≤ C, R ≤ 1000) indicating the number of columns and rows. Then exactly R lines follow, each containing C characters. These characters specify the blue-red-dot-grid in front of you.

Output the longest possible rope length you can make with the grid.

Sample Input

3 3

Sample Output