#K68262. Minimum Additional Ingredients

    ID: 32826 Type: Default 1000ms 256MiB

Minimum Additional Ingredients

Minimum Additional Ingredients

You are given n ingredients, each with a specific freshness level. Your task is to determine the minimum number of additional ingredients required such that there are exactly k distinct freshness levels available.

If the number of unique freshness levels among the given ingredients is \(n_{\text{unique}}\), then the answer is computed as

answer=max(0,knunique)\text{answer} = \max(0, k - n_{\text{unique}})

For example, if you have 5 ingredients with freshness levels [3, 1, 4, 1, 5] and you need 7 distinct levels, you must add 3 more ingredients with new freshness levels.

inputFormat

The input consists of two lines:

  • The first line contains two space-separated integers n and k, where n is the number of ingredients and k is the target number of distinct freshness levels.
  • The second line contains n space-separated integers representing the freshness levels of the ingredients.

outputFormat

Output a single integer, which is the minimum number of additional ingredients required to achieve exactly k distinct freshness levels.

## sample
5 7
3 1 4 1 5
3

</p>