codeforces#P1980A. Problem Generator
Problem Generator
Description
Vlad is planning to hold $m$ rounds next month. Each round should contain one problem of difficulty levels 'A', 'B', 'C', 'D', 'E', 'F', and 'G'.
Vlad already has a bank of $n$ problems, where the $i$-th problem has a difficulty level of $a_i$. There may not be enough of these problems, so he may have to come up with a few more problems.
Vlad wants to come up with as few problems as possible, so he asks you to find the minimum number of problems he needs to come up with in order to hold $m$ rounds.
For example, if $m=1$, $n = 10$, $a=$ 'BGECDCBDED', then he needs to come up with two problems: one of difficulty level 'A' and one of difficulty level 'F'.
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
The first line of each test case contains two integers $n$ and $m$ ($1 \le n \le 50$, $1 \le m \le 5$) — the number of problems in the bank and the number of upcoming rounds, respectively.
The second line of each test case contains a string $a$ of $n$ characters from 'A' to 'G' — the difficulties of the problems in the bank.
For each test case, output a single integer — the minimum number of problems that need to come up with to hold $m$ rounds.
Input
The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.
The first line of each test case contains two integers $n$ and $m$ ($1 \le n \le 50$, $1 \le m \le 5$) — the number of problems in the bank and the number of upcoming rounds, respectively.
The second line of each test case contains a string $a$ of $n$ characters from 'A' to 'G' — the difficulties of the problems in the bank.
Output
For each test case, output a single integer — the minimum number of problems that need to come up with to hold $m$ rounds.
3
10 1
BGECDCBDED
10 2
BGECDCBDED
9 1
BBCDEFFGG
2
5
1