Princess and Hero

Long long ago, in the south of the ancient China, there was a beautiful and kind princess who was loved dearly by the king. But one day, the princess disappeared. The king worried very much. So he sent knights to look for the princess. At last they found that the princess was kidnapped by Diablo (the evilest demon in the world). Since all the knights were terrified, the king was very angry and upset. At the severe time, a young man showed his braveness, he went to rescue the princess lonely at the risk of his life. But there was a big problem in front of him. That is: Diablo was afraid of the sunshine very much. So it lives in a dungeon which was sunless, dank, chilly and full of evil influence. The young man would die if he entered the dungeon without any preparation. The dungeon was built in a big cave under the ground. In front of the dungeon there was a big under-ground hall. So the sunshine from the entrance of the cave was not able to get to the entrance of the dungeon. Therefore the young man could not get into the dungeon. He tried over and over again. At last a method called to his mind. The hall had two entrance, one was the entrance of the cave (we call it the entry), the other was the entrance of the dungeon (we call it the exit). The hall was surrounded by walls except the entry and the exit and there was nothing in the hall. The young man put some mirrors in the hall to make the sunshine beams from the entry get to the exit with the reflection of some mirrors. So that he could kill the Diablo and rescue the princess. Each mirror put in the hall had two reflectible surfaces. The mirrors were put in a special way. So the beam’s angle of incidence was always kept 45 degrees. Therefore the beams always turned left or right in very 90 degrees. Each mirror could take a 90-degree rotation. This means: each mirror had two states, one let the coming beam turn left in 90 degrees, and the other let it turn right in 90 degrees. The walls could absorb any sunshine beams(this means no beams can reflect against the walls). The beams went in a straight line and one beam could go across another beam without any effect on it. But when the young man put the mirrors in the hall, he was too hurry. So some mirrors were in wrong state. It means that the sunshine from the entry could not get to the exit successfully, the young man could not kill Diablo and rescue the princess. The question is how many mirrors’ state must be changed at lease, the sunshine from the entry can get out of the hall from the exit successfully to let the young man kill Diablo and rescue the princess. Input The input file is a plain text file. It represent a series of halls. Each hall description begins with a line containing two integers M and N (3 ≤ M,N ≤ 100), separated by a space, which specify the size of the hall, M rows and N columns. Each line in the following M lines contains N characters without any separators. ‘/’s and ‘\’s represent the mirrors and their states, ‘*’s represent the walls, and ‘.’s represent the spaces. The input file ends if M = 0 and N = 0. Output For each hall, your program should output one integer in one line, which specifies the minimum number of mirrors whose state must be changed. If there is no necessary to change the mirrors’ state, just output ‘0’. If there is no way to make the sunshine from the entry get out of the hall from the exit, output ‘-1’.

2/2 Sample Input 54 **** / ./. .. . 44 .* *.* \ *. 00 Sample Output 3 0