#B4099. Satellite Destruction

    ID: 11756 Type: Default 1000ms 256MiB

Satellite Destruction

Satellite Destruction

In the year 2077, humanity not only see great advances in cyber technology, but also in space technology. The Earth has various artificial satellites in its outer orbits serving different purposes. Since there is an upper limit on the number of satellites in any given orbit and satellites are rapidly replaced by newer models, all old satellites in an orbit must be destroyed before launching new ones.

There are two types of weapons available to destroy the satellites:

  1. Using a fixed-point laser weapon costs 1 \(\rm{PW}\) to destroy a specified satellite on any orbit.
  2. Using a pulse orbital weapon costs \(c\ \rm{PW}\) to destroy all satellites on a chosen orbit.

You are given n old satellites distributed across various orbits. The input provides the orbit number for each satellite. Your task is to compute the minimum cost (in \(\rm{PW}\)) required to destroy all of these satellites. Note that if an orbit contains \(k\) satellites, you may either destroy them one by one at a cost of \(k\) PW or use the pulse orbital weapon for a cost of \(c\) PW. Mathematically, for an orbit with \(k\) satellites, the cost is \(\min\{k, c\}\). The overall minimum cost is the sum of the costs for each distinct orbit.

inputFormat

The first line contains two integers n and c (1 ≤ n ≤ 10^5, 1 ≤ c ≤ 10^9), representing the number of satellites and the cost of using the pulse orbital weapon, respectively. The second line contains n integers, where the i-th integer indicates the orbit number of the i-th satellite. The orbit numbers can be any integer and are not necessarily sorted.

outputFormat

Output a single integer which is the minimum cost required to destroy all the satellites.

sample

3 2
1 2 1
3