SP55 JASIEK - Jasiek
Description
Jasiek is only 6 years old, but he already has many skills. He likes drawing and asking riddles very much. This morning he got a sheet of grid paper and a pencil from his mother and he started drawing. All his drawings have some common properties:
- Jasiek colors full grid squares;
- if some coloured grid squares touch each other, it means they have a common edge or a corner;
- all grid squares are connected, which means between every two coloured grid squares there is a sequence of coloured grid squares, which have a common edge;
- there are no white holes, that is from every white grid box it is possible to draw a line to the boundary of the sheet which never touches any coloured grid square.
At noon mom phoned and asked what Jasiek's today's picture was. The boy didn't answer directly, but described the picture by a sequence of moves needed to walk around the centres of the coloured squares on its boundary, ie. those squares which have at least one common corner with a white square. Jasiek set the starting square and then gave the sequence of moves necessary to walk along the boundary squares anti-clockwise. Mom was very surprised by the complexity of the picture and especcialy by the number of coloured squares. Given Jasiek's description, can you quickly count how many coloured squares there are in the picture?
Task
----
Write a program which
- reads (from standard input) Jasiek's description of the picture,
- counts the number of coloured squares,
- writes out the outcome (to standard output).
Input Format
N/A
Output Format
N/A