QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 64 MB Total points: 10

#10662. Coins [A]

الإحصائيات

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 $ k $ 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 $ k $ times more common than tails.

Input Format

The first line of the standard input contains two integers $ n $ and $ k $ (3 ≤ $ n $ ≤ 1 000 000, 2 ≤ $ k $ ≤ $ n $ - 1). 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 $ n $ characters describing the outcomes of consecutive tosses. It consists of letters O and R denoting heads and tails respectively.

Output Format

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 $ k $ times more heads than tails. If such sequence does not exist, your program should output 0.

Example

Input

15 3
RORROOROOROOORO

Output

8

Notes

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.

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.