Classmates stand in a circle facing inward, each with a direction — left or right — in mind. One student holds a ball and starts the game by tossing it to another student (it does not matter which one).
When a student catches the ball while thinking left, she throws it across the circle to the person one place to the left (from her perspective) of the student who threw the ball to her, and then switches from thinking left to thinking right. Likewise, when she catches the ball while thinking right, she throws it to the person one place to the right of the student who threw it to her, and then switches from thinking right to thinking left.
There are two exceptions:
(These two rules exist to prevent a student from tossing the ball to herself.)
No matter the initial pattern of left/right thinking, and no matter who first receives the ball, every student is eventually tossed the ball. Your task is to determine how long this takes.
You are given the initial directions of n classmates (numbered clockwise) and the classmate to whom classmate 1 first tosses the ball. Classmate 1 always holds the ball at the start.
The input contains several test instances. Each instance has the form
n k t1 t2 t3 ... tn
where n (2 ≤ n ≤ 30) is the number of classmates, numbered 1 through n clockwise around the circle; k (k > 1) is the classmate to whom classmate 1 first tosses the ball; and each ti (i = 1, 2, ..., n) is either L or R, giving the initial direction thought by classmate i. A line containing n = 0 marks the end of the input and is not processed.
For each test instance, print one line of the form
Classmate m got the ball last after t tosses.
Here m is the last classmate to be tossed the ball for the first time, and t is the total number of tosses made at that moment. You may assume that t is never larger than 100000.
Note that classmate 1 starts with the ball and tosses it to classmate k; because classmate 1 was not itself tossed the ball, classmate 1 does not switch the direction he is thinking on that first toss.