Rook in the maze
Rook - it's a chess piece, which in one move can move any number of squares horizontally or vertically. However, it can not "jump" over its stand on the path.
Vasja recently built on a chessboard kind of labyrinth - in some cells of the board, he put the pawn (the most "weak" chess pieces). Now he wants to know, for a minimum number of moves the Rook can get from one cell to another.
He ponders this question for several days, but can not find the answer. So he turned for help to you. Write a program that finds the answer to the problem Vasja.
Input
The first line contains two positive integers: n and m (1 ≤ n, m ≤ 500) - the size of the maze.
Each of the following n rows contain m characters. j-th symbol of the i-th of these lines corresponds to a cell with coordinates (i, j). It is equal to "." (dot) if the cell is empty, P, if busy pawn, S, if the starting cell for the rook, F, if this is the ultimate cage.
Output
In the output file output the minimum number of moves required by the rook to penetrate the cells of the initial to the final. If the final cell is unattainable from the start - output -1.