#P1324C. Frog Jumps
Frog Jumps
No submission language available for this problem.
Description
There is a frog staying to the left of the string consisting of characters (to be more precise, the frog initially stays at the cell ). Each character of is either 'L' or 'R'. It means that if the frog is staying at the -th cell and the -th character is 'L', the frog can jump only to the left. If the frog is staying at the -th cell and the -th character is 'R', the frog can jump only to the right. The frog can jump only to the right from the cell .
Note that the frog can jump into the same cell twice and can perform as many jumps as it needs.
The frog wants to reach the -th cell. The frog chooses some positive integer value before the first jump (and cannot change it later) and jumps by no more than cells at once. I.e. if the -th character is 'L' then the frog can jump to any cell in a range , and if the -th character is 'R' then the frog can jump to any cell in a range .
The frog doesn't want to jump far, so your task is to find the minimum possible value of such that the frog can reach the cell from the cell if it can jump by no more than cells at once. It is guaranteed that it is always possible to reach from .
You have to answer independent test cases.
The first line of the input contains one integer () — the number of test cases.
The next lines describe test cases. The -th test case is described as a string consisting of at least and at most characters 'L' and 'R'.
It is guaranteed that the sum of lengths of strings over all test cases does not exceed ().
For each test case, print the answer — the minimum possible value of such that the frog can reach the cell from the cell if it jumps by no more than at once.
Input
The first line of the input contains one integer () — the number of test cases.
The next lines describe test cases. The -th test case is described as a string consisting of at least and at most characters 'L' and 'R'.
It is guaranteed that the sum of lengths of strings over all test cases does not exceed ().
Output
For each test case, print the answer — the minimum possible value of such that the frog can reach the cell from the cell if it jumps by no more than at once.
Samples
Note
The picture describing the first test case of the example and one of the possible answers:
In the second test case of the example, the frog can only jump directly from to .
In the third test case of the example, the frog can choose , jump to the cell from the cell and then to the cell from the cell .
In the fourth test case of the example, the frog can choose and jump times to the right.
In the fifth test case of the example, the frog can only jump directly from to .
In the sixth test case of the example, the frog can choose and jump times to the right.