PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#CC0000002. Giữ lại không quá K loại (Not so Diverse)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Giữ lại không quá K loại (Not so Diverse)

Not so Diverse

Source: AtCoder Version: Phuoc Hung OJ Extended

Problem Statement

There are NN balls, each labeled with an integer. You may replace the number on any ball with any integer. Find the minimum number of balls that must be relabeled so that at most KK different values remain.

Input

The first line contains NN and KK. The next line contains NN values A1,…,ANA_1,\ldots,A_N.

Output

Print one integer: the minimum number of relabelings.

Subtasks

  • Subtask 1 (20 points): 1≤K≤N≤351\le K\le N\le 35; 1≤Ai≤N1\le A_i\le N.
  • Subtask 2 (30 points): 1≤K≤N≤25001\le K\le N\le 2500; 1≤Ai≤N1\le A_i\le N.
  • Subtask 3 (50 points): 1≤K≤N≤2⋅1051\le K\le N\le 2\cdot 10^5; 1≤Ai≤N1\le A_i\le N.

Examples

Input

7 2
1 2 1 3 3 3 4

Output

2

Explanation

Keep values 11 and 33 (frequencies 22 and 33). Relabel the two balls with values 22 and 44.