printРабочее место участника

printЗадачи

1851. The Beach

Ограничения: время – 1s/2s, память – 32MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод copy
Послать решение Blockly Посылки Темы Где Обсудить (0)

Bill has bought some islands at the ocean in the gross and has decided to sell them off piecemeal. But the buyers are interested only in the sites located on the coast of the ocean.
Bill divided the map of islands into square cells and represented each cell by one character. Bill used the character '.' (dot) for the denotation of water and character '*' (asterisk) for the land. Each character '*' corresponds to one site for sale. There are no other characters on the map.
Write the program, which will help Bill to determine an amount of sites having common boundary with the ocean according to this map. The sites, adjoining only to a lake or a pool, are not taken into account. If water square have not common boundary with the ocean, then it is a pool or a lake.
Input
The first line of the input file contains two integers `N` and `M`, separated by one space, where `N` and `M` are the sizes of the map (`3\ ≤\ N\ ≤\ 200`, `3\ ≤\ M\ ≤\ 200`). The following `N` lines contain `M` characters with each line representing a map of the bought islands. NOTE: The islands do not adjoin to the edges of the map.
Output
Write in the output file an amount of sites located on the coast of the ocean.

Sample Input

8 10
..........
..***.....
.*****....
.**..*....
..****....
........*.
......***.
..........

Sample Output

15
loading