영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)
Problem
Your friend Björn has recently started a large chemistry experiment with the goal of creating a secret protein. All proteins are described with strings of letters from a-z, for example, bcaa and hello. He needs to create several so-called pure proteins. These are proteins consisting of copies of the same letter. To do this, he has microscopic scissors called CRISPR. With these, he can remove up to K adjacent letters. In other words, he can choose an interval with up to K letters to cut out. If a protein is divided into two parts when it is cut, these parts will then be joined together where they were cut.
Since he is very lazy, he wants your help to write a program that calculates the minimum number of times he needs to cut a specific protein to make it pure. Note that the protein must not become an empty string, because in that case it can no longer be used for chemistry.
Input
The first line of input contains a string P (1 ≤ |P| ≤ 50), the protein that Björn wants to make pure. P only consists of characters from a-z.
The next line contains the integer K (1 ≤ K ≤ |P|), the number of characters that Björn can remove in each cut.
Output
Print an integer: the smallest number of cuts Björn needs to make in order to make the protein pure.
Scoring
Your solution will be tested on a set of test groups, each worth a number of points. Each test group contains a set of test cases. To get the points for a test group you need to solve all test cases in the test group.
| Group | Points | Constraints |
|---|---|---|
| 1 | 20 | K=1 |
| 2 | 20 | The protein only consists of the characters a and b. |
| 3 | 60 | No additional constraints. |
Explanation of samples
Sample 1: one optimal way is to first cut the characters pe. This results in the string exemlfall.
We can then cut away fa, resulting in exemlll.
Finally, we cut away exem and are left with lll, a pure protein.
(그림은 원문 저장소에서 볼 수 있습니다)
The picture shows the solution to sample 2. If we cut away all b in the way that the picture describes, the protein becomes pure in two cut.
예제
예제 1
exempelfall 4
3
예제 2
aabbabbba 3
2