Farmer John left some old mirrors outside his house, and his cows, mischievous as ever, stole every one of them.
The cows stood the mirrors up in a rectangular field of N×M squares (1≤N,M≤1000). Each square holds one double sided mirror running between two opposite corners of the square, in one of two orientations. A / mirror connects the lower left corner to the upper right corner, and a \ mirror connects the upper left corner to the lower right corner.
One evening Bessie the cow carries a laser pointer out to the mirror field. Standing outside the field, she shines the beam horizontally or vertically along one row or one column, and the beam bounces off mirror after mirror. Every mirror sits diagonally, so a beam traveling horizontally leaves a mirror traveling vertically, and a beam traveling vertically leaves it traveling horizontally.
Bessie wants to know the largest number of reflections her beam can make. Given the layout of the field, compute that number. If the beam strikes the same mirror more than once, every strike counts.
The first line contains the two integers N and M, separated by a space.
Each of the next N lines contains M characters, either / or \, describing one row of the mirror field.
Print one integer, the largest number of times a horizontal or vertical beam that starts outside the mirror field can be reflected. Print -1 if the beam can be reflected forever.
In the first example Bessie shines the beam downward from above the middle column and it reflects three times.
In the second example the best beam passes through one mirror twice. It touches five different mirrors and reflects six times.