시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB48393882.609%

문제

The kingdom of Lazyland is the home to n idlers. These idlers are incredibly lazy and create many problems to their ruler, the mighty King of Lazyland.

Today k important jobs for the kingdom (k ≤ n) should be performed. Every job should be done by one person and every person can do at most one job. The King allowed every idler to choose one job they wanted to do and the i-th idler has chosen the job ai.

Unfortunately, some jobs may not be chosen by anyone, so the King has to persuade some idlers to choose another job. The King knows that it takes bi minutes to persuade the i-th idler. He asked his minister of labour to calculate the minimum total time he needs to spend persuading the idlers to get all the jobs done. Can you help him?

입력

The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 105) — the number of idlers and the number of jobs.

The second line of the input contains n integers a1, a2, . . . , an (1 ≤ ai ≤ k) — the jobs chosen by each idler.

The third line of the input contains n integers b1, b2, . . . , bn (1 ≤ bi ≤ 109) — the time the King needs to spend to persuade the i-th idler.

출력

The only line of the output should contain one number — the minimum total time the King needs to spend persuading the idlers to get all the jobs done.

예제 입력 1

8 7
1 1 3 1 5 3 7 1
5 7 4 8 1 3 5 2

예제 출력 1

10

예제 입력 2

3 3
3 1 2
5 3 4

예제 출력 2

0

힌트

In the first example the optimal plan is to persuade idlers 1, 6, and 8 to do jobs 2, 4, and 6.

In the second example each job was chosen by some idler, so there is no need to persuade anyone.