Long time ago one man said, that he had explored the corridors of one cave. It means, that he was in all corridors of the cave.Corridors are really horizontal or vertical segments. Corridor counted visited if he was in at least one point of corridor. Now you want to know, is it true. You have a map of the cave, and you know that explorer used the following algorithm: he turns left if he can, if he can't he goes straight, if he can't he turns right, if he can't he turns back.Exploration ends when the man reaches entry point second time. You task to count how many corridors wasn't visited by explorer.