Longest Substring With Exactly K Unique Characters

easy
1. You are given a string(str) and a number K.
2. You have to find length of the longest substring that has exactly k unique characters.
3. If no such substring exists, print "-1".

Input Format

A string

Output Format

A number representing length of the longest K unique characters substring.

Constraints

1 <= length of string <= 10^5
1 <= k <= 26

Example

Input
aabcbcdbca
2
Output
4
Previous
Count Of Substrings Having All Unique Characters
Next
Count Of Substrings With Exactly K Unique Characters

Related Questions