atcoder#ARC140A. [ARC140A] Right String

[ARC140A] Right String

Score : 300300 points

Problem Statement

For a string TT consisting of lowercase English letters, consider the question below, and let f(T)f(T) be the answer.

$$T$$You are given a string $S$ of length $N$ consisting of lowercase English letters. You can perform the operation below at most $K$ times (possibly zero). $$
  • Choose a character of SS and change it to any lowercase English letter.

Find the minimum possible value of f(S)f(S) after your operations.

Constraints

  • 1N20001 \le N \le 2000
  • 0KN0 \le K \le N
  • SS is a string of length NN consisting of lowercase English letters.
  • NN and KK are integers.

Input

Input is given from Standard Input in the following format:

NN KK

SS

Output

Print the answer.

4 1
abac
2

If you change the fourth character c to b in the first operation, you get S=S= abab, with f(S)=2f(S)=2.

f(S)f(S) cannot be made 11 or less in one or fewer operations, so the answer is 22.

10 0
aaaaaaaaaa
1
6 1
abcaba
3