F. Square between flowers
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Diana dreamed of a strange black and white field, in which each cell is painted either black or white. Diana immediately came up with the idea of building a wall at the junction of two cells, but only if they are of different colors; it is not allowed to build walls on the border of the field.

But now she wonders what is the length of the side of the largest square that can be enclosed by walls according to the described rules. Only you can save her by telepathically sending the answer to her dream. Hurry up! Diana is about to wake up and go to school.

If it is impossible to enclose a square, output 0.

Input

The first line contains two natural numbers $$$n, m$$$ $$$(3 \le n, m; n \cdot m \le 3 \cdot 10^5 )$$$ — the dimensions of the field. Then $$$n$$$ lines of length $$$m$$$ are entered, describing the field.

Output

Output a single number - the length of the side of the largest square.

Examples
Input
5 6
BBBBWB
WBWWBW
BWBWBB
BWWBBW
WBWBBW
Output
2
Input
4 4
WBWB
BWWW
WWWB
BWBW
Output
0
Input
3 3
BWW
WBW
WWB
Output
1
Note

The picture corresponds to the first example, the desired square with a side of 2 is highlighted, it is obvious that a larger square cannot be enclosed: