Mock CCC '19 Contest 1 S2 - Rimuru's Shapes

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type
Rimuru Tempest, founder of the country Tempest (slime + human form).

Rimuru Tempest, the founder of the country Tempest, has found a new hobby. He likes to sculpt random shapes that come to his mind.

Initially, Rimuru Tempest has sculpted N shapes, writing an integer A_i on the i^{th} shape. The point of this is to have D different numbers in total, except... he made a mistake. He may have less than or more than D unique numbers!

As a servant of the almighty Rimuru Tempest, you cannot disappoint your King. Can you find the minimum number of shapes that need to have their numbers rewritten to have D different numbers?

Constraints

  • 1 \le D \le N \le 500000
  • 1 \le A_i \le N

Input Specification

The first line of input will contain two integers, N and D, each separated by a space.

The next line of input will contain N space separated integers, A_i, such that the input is given as A_1, A_2, \dots, A_N.

Output Specification

You are to print a single integer, the minimum number of shapes that you need to rewrite the integers on them.

Sample Input 1

5 2
1 1 2 2 5

Sample Output 1

1

Comments

There are no comments at the moment.