Saiki has bought some of his favourite coffee jelly and wishes to enjoy his treats in peace and quiet.
The school is mapped as a rectangle of length and width . Using his psychic powers, Saiki has created a 2d map of the single floored school, where X
marks the walls and doors, *
represents people and .
represents open space. A classroom is a group of open space cells vertically or horizontally connected. A classroom is considered empty if none of the open cells are vertically or horizontally connected to a person.
Saiki wants to enjoy his treats alone, so he asks you: how many empty classrooms are there where he can enjoy his treats?
Constraints
Input Specification
The first line contains 2 non-negative integers and .
The following lines will each contain characters, representing the school.
Output Specification
Output the number of empty classrooms in the school.
Sample Input 1
6 10
XXXXXXXXXX
X.*.X..X.X
XX.XXXXXXX
XXXX..XXXX
*.......XX
XXXXXXXXXX
Sample Output 1
2
Explanation for Sample Output 1
4 groups of open cells exist, 2 of which do not contain people.
Sample Input 2
7 6
XXX..X
..XXX*
XXXXXX
..*...
XXXXXX
XXXXX.
......
Sample Output 2
3
Explanation for Sample Output 2
5 groups of open cells exist, 3 of which do not contain people.
Comments