eolymp
bolt
Try our new interface for solving problems
Problems

Cell removal

Cell removal

From a rectangular sheet of paper (m rows, n columns) some cells are removed. In how many pieces the sheet will be fall apart? Two cells do not fall apart if they have a common side.

Input

The first row contains the numbers m and n (1m, n100). Each of the following m lines contains n symbols. If the cell is not cut, it is represented with the # sign, if it is cut, it is given with a point.

Output

Print the number of parts of the sheet.

Time limit 1 second
Memory limit 128 MiB
Input example #1
4 8
#.##.#.#
......##
#.###.##
##.##.##
Output example #1
6