Not so rude!
After many adventures, T'Challa faces his final battle against Killmonger. However, since both heroes are exhausted, they decide to resolve their differences through a more peaceful intellectual competition.
The competition rules are as follows: Killmonger first creates a string , composed of lowercase Latin letters.
The roughness of a string is defined as the number of pairs of integers , where , such that «a
» and «b
». In other words, the roughness is the number of ways to delete all characters except two, leaving the sequence «a
» followed by «b
».
Once Killmonger has created the string, T'Challa must select a non-empty substring . The roughness of this chosen substring must not exceed the number , or T'Challa will face a technical defeat for exceeding the allowed roughness.
T'Challa wins if he selects the longest possible substring from all those whose roughness does not exceed . If there are multiple substrings of maximum length, any of them will suffice. T'Challa doesn't need your help in finding the substring itself, but he asks you to determine the maximum possible length of such a substring.
Input
The first line of input contains two integers and —the length of the string created by Killmonger, and the maximum allowed roughness of the chosen substring (, ).
The second line contains the string , created by Killmonger. The string consists of lowercase Latin letters.
Output
Output a single number—the maximum length of a substring of the given string that has a roughness not exceeding .
Examples
Scoring
This problem includes six subtasks. Each subtask has additional constraints as specified below. To earn points for a subtask, you must pass all tests for that subtask, as well as all tests for all preceding subtasks.
( points): ;
( points): ;
( points): ;
( points): ;
( points): ;
( points): full constraints.