A string consists of only 'a' and 'b' as the characters. The perfectness of the string is described as the maximum length substring of equal characters. Given is a number k which denotes the maximum number of characters he can change. Find the maximum perfectness one can generate by changing no more than k characters.
Input Format
The first line contains an integer denoting the value of K. The next line contains a string having only ‘a’ and ‘b’ as the characters.
Constraints
2 ≤ N ≤ 10^6
Output Format
A single integer denoting the maximum perfectness achievable.
Sample Input
2
abba
Sample Output
4
Explanation
We can swap the a's to b using the 2 swaps and obtain the string "bbbb". This would have all the b's and hence the answer 4.
Alternatively, we can also swap the b's to make "aaaa". The final answer remains the same for both cases.
question from:
https://stackoverflow.com/questions/65930986/strings-replacing-the-characters-to-obtain-perfect-string 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…