Joe claims that he has telekinetic abilities. This statement has shocked Stan, who is a confirmed rationalist, and he immediately wanted Joe to prove it.
Joe decided to toss a coin to show what he is capable of.
He says that he can do it in such a way, that there will be exactly times more heads than tails.
Stan has written down the results for all tosses and now he wants to find the longest sequence of consecutive tosses, in which heads are exactly
times more common than tails.
The first line of the standard input contains two integers and
(
,
).
The first is the number of tosses made by Joe, whereas the meaning of the second number has already been described in the task statement.
The second line contains a sequence of
characters describing the outcomes of consecutive tosses.
It consists of letters O and R denoting heads and tails respectively.
Your program should output one integer to the first and only line of the standard output equal to the length of the longest sequence of consecutive tosses, in which there are exactly times more heads than tails.
If such sequence does not exist, your program should output
.
For the input data:
15 3 RORROOROOROOORO
the correct result is:
8
Explanation of the example: The series from fifth to twelfth as well as from sixth to thirteenth toss contain exactly 6 heads and 2 tails, i.e., three times more heads than tails. There does not exist a longer sequence with this property.
Task author: Tomasz Idziaszek.
In the event of technical difficulties with Szkopuł, please contact us via email at [email protected].
If you would like to talk about tasks, solutions or technical problems, please visit our Discord servers. They are moderated by the community, but members of the support team are also active there.