QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 32 MB Total points: 10

#11652. Words

الإحصائيات

By a word we mean a sequence of capital letters of the English alphabet. The length of a word is the number of letters contained in it. This way, word $ α $ = ABAACBBBA is of length 9. By a block within a word we understand maximal consistent subsequence of the same letters. A word is called $ t $-hard, if it contains $ t $ blocks. Taking into consideration the word $ α $, it turns out to be 6-hard, because it consists of the following blocks: A|B|AA|C|BBB|A.

If two given words are of the same length, it is possible to check how different they are. Two words of the length $ n $ are $ k $-different, if for exactly $ k $ positions $ i $ (1 ≤ $ i $ ≤ $ n $), $ i $'th letter of the first word is different from $ i $'th letter of the second word. Checking two words $ α $ and $ β $ = AAAABBBBB, it turns out that they are 3-different.

For a given word $ α $, we want to find not too different word $ β $, so that it is not too complicated. Your task is to define, how simple $ β $ can be.

Write a program which:

  • reads the numbers $ n $, $ k $ and a word $ α $ of length $ n $;
  • determines the minimal value of $ t $, so that there exists a $ t $-hard word $ β $, which is at most $ k $-different from $ α $ (which is, there is no $ k $' > $ k $, so that $ α $ and $ β $ are $ k $'-different);
  • writes the answer to the standard output.

Input Format

In the first line of the standard input there are two integers $ n $, $ k $ separated with a single space (1 ≤ $ n $ ≤ 1 000, 0 ≤ $ k $ ≤ $ n $). They represent adequately: the length of the word $ α $ and the allowed level of difference. In the second line there are exactly $ n $ capital letters forming the word $ α $.

Output Format

One integer is to be written to the standard output - $ t $.

Example

Input

9 3
ABAACBBBA

Output

2
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.