Robot
The movement of the robot is controlled by the program. The program consists of the following commands:
S - make a step forward
L - rotate 90° left
R - rotate 90° right
Write a program that, according to a given program for the robot, will determine how many steps it will take before returning for the first time to the place which it has already visited, or will establish that this will not happen.
Input
One line of uppercase Latin letters S, L, R, describing the program for the robot. The total number of commands in the program does not exceed 200, the number of S commands no more than 50.
Output
Print one number, the number of steps to be taken (that is, the number of S commands to be executed) before the robot first comes to the place which it already passed. If this does not happen, output the number -1.