Олимпиадный тренинг

Задача 33513. Beds*


Задача

Темы: Обход в глубину
A rectangular garden plot N meters wide and M meters long is divided into squares with a side of 1 meter. Beds have been dug up in this area. A bed is a collection of squares that satisfies the following conditions:

* from any square of this bed you can get into any other square of the same bed, successively moving along the bed from square to square through their common side;
* no two beds intersect and do not touch each other either on the vertical or horizontal sides of the squares (touching the beds with the corners of the squares is allowed).
Count the number of beds in the garden.

Input
The first line contains the numbers N and M separated by a space, followed by N lines of M characters each. The symbol # denotes the territory of the beds, the dot corresponds to the unoccupied territory. There are no other characters in the original file. 1≤ N, M≤ 200.

Imprint
Print one number - the number of beds in the garden.


Examples
# Input Output
1 5 10
##..#####.
.#.#.#....
###..##.#.
..##.....#
.###.#####
5