Pair Count
We define the value of a string T of length m as the number of pairs (i,j) such
that i<j, Ti is m, and Tj is u.
Given a string S of length N and an integer C, find the maximum possible value of X such that there exists a contiguous substring of S with length X and value at most C.
Input
The first line contains two integers N and C.
The second line contains the string S of length N.
Output
Print a single integer representing the maximum possible length X.
Constraints
- 1≤N≤106
- 1≤C≤1018
- S consists only of lowercase English letters.
Example 1
10 3
mumumumumu
6
Explanation
The longest substring of S that has the value ≤3 is umumum.
Example 2
8 1
monashuni
8
Comments0
No comments yet
Be the first to comment.
New comment
Log in to join the discussion.