A frozen lake is modeled as a grid of R rows and C columns. Each cell is either ice (#) or open water (.). An ice floe is a maximal group of ice cells connected through shared edges: from an ice cell you may step to an ice cell directly above, below, to the left, or to the right (not diagonally).
Count the number of distinct ice floes.
Input format
Line 1: two integers R and C.
Next R lines: a string of exactly C characters each, using # for ice and . for water.
Output format
A single integer: the number of ice floes.
Constraints
- 1 <= R, C <= 1000
- Every grid character is either
#or..