Problem B
Pencil Crayons
Mr. Daniels bought a set of
Mr. Daniels has a gap in his schedule and the break room is
currently undergoing maintenance. He might as well rearrange
the pencil crayons so each box again has exactly
Help Mr. Daniels figure out the minimum number of pencil
crayons that need to be removed so that he can place them back
in boxes to ensure each box again has
Input
The first line of input contains two integers
Each string describing a colour will have a length between
Output
Output a single number indicating the fewest pencil crayons
that need to be removed from all boxes so that Mr. Daniels can
place them back in the boxes while ensuring each box has
exactly
Sample Input 1 | Sample Output 1 |
---|---|
2 3 red blue red green green blue |
2 |
Sample Input 2 | Sample Output 2 |
---|---|
3 2 orange white orange orange white white |
2 |
Sample Input 3 | Sample Output 3 |
---|---|
2 2 aubergine chartreuse chartreuse aubergine |
0 |
Sample Input 4 | Sample Output 4 |
---|---|
4 3 a a a b c c c b a b b c |
4 |