LearnPy Hub
← Arena
AdvancedRating 1500

At Most K Distinct

Print the length of the longest substring with at most k distinct characters.

Input

A string, then k ≥ 1.

Output

A length.

Sample 1

Input
eceba
2
Output
3

Sample 2

Input
aa
1
Output
2
solution.py
Output appears here
At Most K Distinct · Python Arena problem · LearnPy Hub