Pair Count

View as PDF

Submit solution

Points: 100
Time limit: 1.0s
Memory limit: 977M

Problem type

We define the value of a string T of length m as the number of pairs (i, j) such that i < j, T_i is m, and T_j 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 \le N \le 10^6
  • 1 \le C \le 10^18
  • S consists only of lowercase English letters.

Example 1

Input
10 3
mumumumumu
Output
6
Explanation

The longest substring of S that has the value \le 3 is umumum.

Example 2

Input
8 1
monashuni
Output
8

Comments

There are no comments at the moment.