P28471 [洛谷] [COCI2009-2010#5] ZUMA
提高
题目描述

Problem Description

Translated from COCI 2010.03.06 T4 "ZUMA"

Mirko has arranged \( N \) marbles in a row, numbered from \( 1 \) to \( N \). The color of the \( i \)-th marble is \( c_i \). He notices that if he touches \( \geq K \) consecutive marbles of the same color, a magic spell will cause these marbles to disappear; thereafter, the marbles before these \( K \) marbles will be adjacent to the marbles after these \( K \) marbles.

Mirko has many marbles at home and wants to insert as few marbles as possible between the \( N \) marbles (or even before the first marble or after the last marble) so that all \( N \) marbles plus the inserted marbles disappear.

Input Format

The first line contains \( N \) and \( K \).
The second line contains \( c_1 \ldots c_N \).

Output Format

A single line with an integer representing the minimum number of marbles he needs to insert.

Sample Input and Output

Sample Input #1

2 5
1 1

Sample Output #1

3

Sample Input #2

5 3
2 2 3 2 2

Sample Output #2

2

Sample Input #3

10 4
3 3 3 3 2 3 1 1 1 3

Sample Output #3

4

Notes/Hints

\( 1 \leq N \leq 100 \), \( 2 \leq K \leq 5 \), \( 1 \leq c_i \leq 100 \).

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 5 1 1
样例输出
3