#K51507. Maximum Elements Removal

    ID: 29102 Type: Default 1000ms 256MiB

Maximum Elements Removal

Maximum Elements Removal

You are given an array of positive integers and an integer (k). You can perform the following operation an arbitrary number of times: select a subsequence of the array with exactly (k) elements, where all the elements in the subsequence are equal, and remove them from the array. Your task is to determine the maximum number of elements that can be removed from the array by repeatedly applying this operation.

Note: The subsequence does not need to be contiguous.

inputFormat

The first line contains two integers (n) and (k) separated by a space, where (n) is the number of elements in the array and (k) is the length of the subsequence to be removed.

The second line contains (n) space-separated positive integers representing the array.

outputFormat

Print a single integer — the maximum possible number of elements that can be removed by performing the defined operation.## sample

5 2
1 2 2 3 3
4