GALERIJA
문제
Map of an art gallery can be represented by a square grid of M columns and N rows. Some of the squares are walls while others represents empty space.
Rooms consist of adjacent free squares (squares that share edge). On the walls of the rooms we want to hang as many pictures as possible. Every picture occupies exactly two lengths of a square and their height doesn’t matter. In other words you can hang a picture on the wall if there are two consecutive walls and two free squares opposite of them (that two free squares should, of course, be at the same side of walls).
Write a program that computes the maximum number of pictures that can be hanged on the walls.
[이미지 1]
This picture shows one of the possible solutions for a gallery map.
입력
In the first line of the input file there are two integers M and N, 1 ≤ M,N ≤ 1000, number of the rows and number of the columns of the gallery.
In the next M rows there are N characters. Every character represents either a free square or wall. ‘X’ represents wall and ‘.’ represents free space.
First and last row, as well as first and last column are walls.
출력
In the first line of file you should write maximum number of pictures that can be hanged on walls of gallery
예제
예제 1
3 3 XXX X.X XXX
0
예제 2
5 5 XXXXX X...X X.XXX X.X.X XXXXX
4
예제 3
7 10 XXXXXXXXXX X.X.X....X XXX.X.XX.X XX....XX.X X.XX..X..X X..XX...XX XXXXXXXXXX
14