#t450. 数水洼

数水洼

Puddles

Problem Description

There is a plot of land of size N×MN \times M. After rain it has pools of water: W marks water and . marks dry ground. Two water cells that are 8-connected are considered part of the same puddle. Count the number of puddles in the yard.

Input Format

The first line contains N,MN, M (1≤N,M≤1101 \le N, M \le 110).

The next NN lines give the N×MN \times M land map.

Output Format

One line: the number of puddles.

Sample Input

10 12
W........WW.
.WWW.....WWW
....WW...WW.
.........WW.
.........W..
..W......W..
.W.W.....WW.
W.W.W.....W.
.W.W......W.
..W.......W.

Sample Output

3

Limitation

1 s, 1024 KiB for each test case.