АВТ
Язык:

Дистанционный практикум по программированию

Задачи Online статус Соревнования
Новости Справка СДО
 
Здравствуйте, Гость! Войдите с паролем или зарегистрируйтесь.

1138. Остров

Ограничение времени: 1 сек.
Ограничение памяти:65536 КБайт
Баллы:100
Статистика Послать на проверку Задачу добавил debug

Условия с турнира школьников на русском языке

On February 30th this year astronauts from the International Space Station flew over the Pacific Ocean and took a picture, on which was discovered a previously unknown island. On the digitized picture the island appears as a connected set of square cells. This means that someone can reach some cell of land from some other cell land, going from cell to cell through their common side. There is no other water area within the island. The island is surrounded by water.

The coastline of the island is a closed polygonal line. The water cell are marked by minus sign ("–"), and the land cell – by plus sign ("+").

The coastline cell is a cell, which have a common border with water cell. In the figure below the length of the coastline is 14 cells. The other five cells of land are internal cells of the island.

Write a program that, given dimensions of the rectangle n and m and digitized picture, calculates l – the number of cells that form the coastline of the island.

 

Limitations

3 <= n, m <= 1 000, l > 0.

 

Input

The first line of input file contains two integers n and m. The following n lines contain m characters (the char "–" – cell with water, and the "+" – cell with land)

 

Output (Output)

The output file should consist of one integer l – the number of cells that form the coastline of the island.

 

Examples

Input

Output

7 8

––––––––

–––+++––

–––+++––

–+++++––

–+++++––

––++–+––

––––––––

14

 

Input

Output

3 3

–––

–+–

–––

1


 

 

All Rybinsk-2012 problems (in PDF)


Статистика Послать на проверку Обсуждение задачи Автор/источник:
Задачи с соревнований и сборов / Чемпионат мира по программированию (ICPC) / Рыбинск-2012 /
1137. A - Ханойская башня 1138. 1139. C - Последовательность. 1140. D - Selection 1141. E - Головоломка
Задачи с соревнований и сборов / Чемпионат мира по программированию (ICPC) / Школьники-Рыбинск-2012 /
1137. A - Ханойская башня 1138. 1143. C - Функция 1148. D - Малина 1139. E - Последовательность.
 
время генерации 0.078 сек.
© Copyright ВоГУ, АВТ, Носов Д.А., Андрианов И.А.