Longest Substring with At Most K Distinct Characters
Find the length of the longest substring containing at most K distinct characters.
Input format
The first line contains a string S. The second line contains K.
Output format
Print the length of the longest substring with at most K distinct characters.
Constraints
- Values fit in a 64-bit signed integer
- Trailing whitespace and a trailing newline are ignored by the judge
Read from stdin, write to stdout. Sample cases below show the exact format.
Sample cases
Example 1
Input
eceba 2Expected output
3Example 2
Input
aa 1Expected output
2