#P2418. Dormitory Allocation Problem

    ID: 15689 Type: Default 1000ms 256MiB

Dormitory Allocation Problem

Dormitory Allocation Problem

There are \(N\) students (other than the special ones) in the school. Each student worships one of the "great experts." The teacher now needs to assign dormitories for these \(N\) students. However, a problem arises:

In the same dormitory, the students must either all worship the same expert, or, if they worship different experts, they must worship only yyy and c01 and the absolute difference between the number of students who worship yyy and those who worship c01 does not exceed \(M\), i.e. \(|\#\{\text{yyy}\} - \#\{\text{c01}\}| \le M\). Otherwise, a conflict will occur.

For convenience, the teacher has arranged the \(N\) students in a line, and only consecutive students can be assigned to the same dormitory.

Assuming that each dormitory can accommodate an arbitrary number of students, determine the minimum number of dormitories required.

inputFormat

The first line contains two integers \(N\) and \(M\) separated by a space.

The second line contains \(N\) strings separated by spaces, where each string represents the expert that the corresponding student worships.

outputFormat

Output a single integer representing the minimum number of dormitories needed.

sample

5 1
aaa aaa yyy c01 yyy
2