CF525D Arthur and Walls

Description

Finally it is a day when Arthur has enough money for buying an apartment. He found a great option close to the center of the city with a nice price. Plan of the apartment found by Arthur looks like a rectangle $ n×m $ consisting of squares of size $ 1×1 $ . Each of those squares contains either a wall (such square is denoted by a symbol "\*" on the plan) or a free space (such square is denoted on the plan by a symbol "."). Room in an apartment is a maximal connected area consisting of free squares. Squares are considered adjacent if they share a common side. The old Arthur dream is to live in an apartment where all rooms are rectangles. He asks you to calculate minimum number of walls you need to remove in order to achieve this goal. After removing a wall from a square it becomes a free square. While removing the walls it is possible that some rooms unite into a single one.

Input Format

N/A

Output Format

N/A