LogiQuest

116. Longest Run After K Changes

MediumSliding Window

You may change at most k characters of the uppercase string to any letters. Print the length of the longest substring of equal letters you can get.

Input format

Line 1: s Line 2: k

Output format

The maximum length.

Example 1

Input

ABAB
2

Output

4

Example 2

Input

AABABBA
1

Output

4

Constraints

1 ≤ |s| ≤ 10⁵ 0 ≤ k ≤ |s|

Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.

Loading the MyLoginn IDE…