Cell removal
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
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 (1 ≤ m, n ≤ 100). 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.
Examples
Input #1
Answer #1
Submissions 5K
Acceptance rate 46%