A transmission is a string of lowercase English letters. Find the length of the longest contiguous substring such that every distinct letter appearing in that substring appears at least k times within it. If no non-empty substring satisfies this, the answer is 0.
Input format
Line 1: the string of lowercase English letters.
Line 2: an integer k.
Output format
A single integer: the length of the longest qualifying substring, or 0 if none exists.
Constraints
- 1 <= length of the string <= 40
- 1 <= k <= 40
- The string consists only of lowercase English letters.