HZNUOJ

Lakes in HZNU

Tags:
Time Limit:  1 s      Memory Limit:   128 MB
Submission:229     AC:74     Score:95.56

Description

Nowadays, because of the wave of cold, long periods of rain appears in HZNU and leads to the result that there are many little lakes here and there. Now, CCJ is interested in the lakes.

To simplify the problem ,we considerthe map of HZNU is a rectangle of the size n×m, which consists of cells of size 1×1. Each cell is either land or water, and lake is a set of water cells. The map is surrounded by water.Two cells are considered adjacent when they share a side (e.g. [x][y] and [x][y-1] are adjacent while [x][y] and [x-1][y-1] are not. ) If and only if two cells are adjacent, they can be merged into the same lake. Obviously, if the water cell in the map is adjacent with the border, it can't be a lake.

your task is to calculate the number of lakes in the map.

See the sample for more details.

Input

The first line of inputs contain two integers n,m (3<=n,m<=100)------the size of the map.

Then n lines contain m characters each to describe the map,each character is a '*'(it means this cell is land) or '.'(it means this cell is water).

This problem you don't need to input multiple test cases.

Output

Output the number of lakes in the map.

Samples

input
5 4 **** *..* **** **.* ..**
output
2
input
3 3 .*. *.* .*.
output
1
input
3 3 ... ... ...
output
0

Hint

这题我从Codeforces723D改编过来,过了这题的同学可以去试试。

http://codeforces.com/problemset/problem/723/D

Author

CHEN, Zequn

Source

杭州师范大学第十届程序设计竞赛