eolymp
bolt
Try our new interface for solving problems
Problems

Holey fabric

Holey fabric

On the table lay a few pieces of fabric, not overlapping each other. These pieces may have holes, including is so large that they can fit a piece of cloth. Was a black and white image of a table surface on which the area covered with a cloth is represented by a *, and free premises - points. One piece of cloth, thus presenting a \textbf{4}-connected region of the characters *, that is, group *, adjacent to each other horizontally or vertically but not diagonally. .***..*** .*.*.**.* .***.*.** *...**.*. In the diagram, three pieces - one without holes, and two - with one hole each: the first area of \textbf{8}, the second - an area of \textbf{12}. Your goal - to find a piece with the greatest number of holes in it. Hole - a \textbf{4}-connected region of points, is completely surrounded by a *. If some pieces have the same number of holes, you should choose a piece of minimum area. \InputFile The first line contains two numbers \textbf{W} and \textbf{H}, separated by spaces. The next \textbf{H} rows of \textbf{W} contain characters each. The symbols in these rows or *, or a point. \textbf{1} ≤ \textbf{W}, \textbf{H} ≤ \textbf{100}. \OutputFile Print a single integer - the minimum area of the holey pieces. If no pieces with holes, the output file should contain zero.
Time limit 1 second
Memory limit 64 MiB
Input example #1
9 5
.********
.*......*
.*..**..*
.*......*
.********
Output example #1
22