11714 - Ponds   

Description

HT Chen gives you a map sized m ✕ n consists of only two symbols '~' and'.', representing water and land, respectively. He wonders how many ponds (consecutive position of water) are there on the map. He has a thought that if he can write a recursive function, the problem may be very easy to solve!

Input

The first line contains two integer mn, representing the size of the map Frank gives to you.

The next m lines contain n characters, either '~' or '.', representing the status of position aij.

It is guaranteed that :

  • 1 ≤ m, n ≤ 1000

Output

Please output the number of ponds on the map.

Sample Input  Download

Sample Output  Download

Tags




Discuss