Counting Rooms
A grid cell is either floor . or wall #. Two floor cells belong to the same room when connected through shared sides. Count the rooms.
Input
The first line contains n and m. The next n lines contain the grid.
1 <= n, m <= 1000
Output
Print the number of rooms.
Example
Input
5 8
########
#..#...#
####.#.#
#..#...#
########
Output
3
Comments