Ensure that you are logged in and have the required permissions to access the test.

Number of Rooms

0

0 votes
Problem

You are given a map of a building, and your task is to count the number of its rooms. The size of the map is n×m squares, and each square is either floor or wall. You can walk left, right, up, and down through the floor squares.
A room is completely surrounded by walls on all sides and can have walls in between.

 

Input

The first input line has two integers n and m: the height and width of the map.

Then there are n lines of m characters describing the map. Each character is either . (floor) or # (wall).

Output

Print one integer: the number of rooms.

Constraints

1≤n,m≤1000

 

Sample Input
5 8
########
#..#...#
####.#.#
#..#...#
########
Sample Output
3
Time Limit: 5
Memory Limit: 256
Source Limit:
Editor Image

?