problem-3-16

Sanket being a stud, wants to gift chocolates on "Chocolate Day" to a girl. He has N chocolates of different types. The chocolates are numbered from 1 to N. There are K types of chocolates, numbered from 1 to K. Also, there  are infinite chocolates of each type. But, the girl is very demanding. She wants all chocolates of same type.

It takes one minute to change chocolate of one type to another type. 
Your task is to change some chocolates (possibly zero) so that all chocolates are of same type.

Given the initial types of all the chocolates, find the minimum amount of time you need to fulfill your task. 

Sanket asks for your help!

Input format
The first line of input contains one integer T denoting the number of test cases.

The first line of each test case contains two space separated integers N and K.

The second line of each test case contains N space separated integers denoting initial types of the chocolates.

Output format
Output one integer per line for each test case, the minimum amount of time required to get all chocolates of same type.

Constraints

 1 ≤ T ≤ 2*10^4 
 1 ≤ N ≤ 10^5 
 1 ≤ K ≤ 10 
 1 ≤ initial types of chocolates  ≤ K 
sum of N over all test cases  ≤ 5*10^5 

*Note : There is no partial scoring for this problem *

SAMPLE INPUT
1
3 2
1 1 2

SAMPLE OUTPUT
1

Explanation

We want the third chocolate of type 1 which takes one minute

Source: hackerearth | Difficulty: EASY


Solutions: