AtCoder Regular Contest 140
A
Right String
AtCoder
⌀ 951
原题
←B →
翻译中…

Problem Statement

翻译中…

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

翻译中…

Find the number of different strings obtained by performing the following operation any number of times: delete the first character from

T

and append it to the end.

翻译中…

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 $S$ and change it to any lowercase English letter.
翻译中…

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

翻译中…

Constraints

翻译中…
  • $1 \le N \le 2000$
  • $0 \le K \le N$
  • $S$ is a string of length $N$ consisting of lowercase English letters.
  • $N$ and $K$ are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N K
S

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
4 1
abac
Output #1
2
If you change the fourth character `c` to `b` in the first operation, you get $S=$ `abab`, with $f(S)=2$. $f(S)$ cannot be made $1$ or less in one or fewer operations, so the answer is $2$.
Input #2
10 0
aaaaaaaaaa
Output #2
1
Input #3
6 1
abcaba
Output #3
3
题目信息
题号
arc140_a
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。