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

Задача 38284. ASCII graphics


Задача

Темы:
A long time ago, most personal computers were equipped with video cards that worked only in text mode. If the programmer wanted to draw a picture on the screen, he had to use pseudographics or ASCII graphics. Here is an example of a picture drawn with it:
^..^
(OO)
/ \
()()
You are given a polygon drawn using ASCII graphics. Your task is to count the number of its sides.
The picture consists of the characters ‘.’, ‘\’ and ‘/’. Each symbol represents a single square of the picture. The ‘.’ denotes an empty square, the character ‘/’ — a square with a segment from the lower left corner to the upper right, and the symbol ‘\’ — a square with a segment from the upper left corner to the lower right.


Input
The first line of the input contains two numbers h and w — image height and width (2 ? h, w ? 100). The next h lines, w characters each, contain the description of the  polygon drawn using ASCII graphics.
It is guaranteed that the picture contains exactly one polygon that does not have self-intersections and self-contacts.

Imprint
Print one number — the number of sides of the polygon.
Examples
# Input Output
1 4 4
/\/\
\../
.\.\
..\/
8