Gljive
Super Mario saved the princess from the castle. Rather than thank him, the princess left the Super Mario and fled to the Evil Crocodile. In fact, she fell in love during his stay in the castle (suspicion of some love potions). Super Mario seeks comfort in mushrooms from the Netherlands. We have walls and mushrooms. Super Mario, even if the super, we can not through walls. I can up, down, left and right (on the plan). But it can be teleport. Once. At the beginning. Teleport want to one place from which will be able to eat mushrooms farther. Tell him how much the maximum fungus can eat as there are separate rooms in the castle (rooms are set so that the squares in each box in the room can be reached at each other).
Input
5 5
..#..
.G#.G
.G###
...#.
...#GOutput
2
3Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.