1089_L. Lazyland_28530
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 a_i. 

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 b_i 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? 

Input

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

The second line of the input contains n integers a_1, a_2, …, a_n (1 ≤ a_i ≤ k) — the jobs chosen by each idler.

The third line of the input contains n integers b_1, b_2, …, b_n (1 ≤ b_i ≤ 10^9) — the time the King needs to spend to persuade the i-th idler.

Output

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.

Examples

Input


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


Output


10


Input


3 3
3 1 2
5 3 4


Output


0

Note

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.
n, k = map(int, raw_input().split())

a = map(int, raw_input().split())
b = map(int, raw_input().split())

jobs = [[] for i in xrange(k)]
s = set()

for i in xrange(n):
    jobs[a[i] - 1].append(b[i])
    s.add(a[i] - 1)

free = []
for i in xrange(k):
    jobs[i] = sorted(jobs[i])
    if len(jobs[i]) < 2:
        continue
    jobs[i].pop()
    for j in jobs[i]:
        free.append(j)

free = sorted(free)
print sum(free[ : k - len(s)])
3 3
3 1 2
5 3 4
 8 7
1 1 3 1 5 3 7 1
5 7 4 8 1 3 5 2
 2 2
1 1
1117 13
 2 1
1 1
7 13
 13 11
6 1 9 9 10 7 3 11 1 4 11 4 11
48 19 90 85 6 46 38 99 41 67 79 1 27
 1 1
1
1000000000
 13 3
3 1 3 1 1 1 3 3 1 3 3 3 3
38 75 29 50 99 5 44 33 45 71 3 57 57
 14 6
2 3 6 6 6 2 5 3 5 5 5 6 5 5
56 41 19 81 19 32 99 37 97 20 90 44 19 79
 10 10
6 6 2 5 1 1 5 5 6 6
48 40 40 98 40 97 90 91 41 36
 18 12
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47 4 41 56 75 16 29 45 100 76 53 48 79 30 56 84 60 86
 18 12
2 9 6 7 12 8 1 1 2 2 1 1 7 11 9 7 8 11
43 40 3 7 5 55 95 1 19 61 41 15 24 10 52 42 47 55
 15 15
12 1 9 10 9 10 2 5 10 12 2 10 2 1 8
47 20 16 2 55 93 53 11 24 74 31 17 32 95 91
 16 16
8 7 9 6 9 16 11 13 13 15 8 5 4 4 9 4
16 45 45 34 51 58 89 73 28 4 85 54 18 56 97 24
 12 9
6 8 2 6 8 2 6 6 6 5 1 1
59 27 78 92 31 26 59 12 80 77 94 31
 19 2
1 1 1 2 2 1 1 2 1 2 2 2 2 2 2 2 1 2 2
92 91 86 3 32 40 25 14 51 10 53 35 28 51 60 73 31 22 66
 2 2
2 2
7 13
 2 1
1 1
6 13
 13 11
6 1 9 9 10 7 3 11 1 4 11 4 11
48 19 90 85 2 46 38 99 41 67 79 1 27
 13 3
3 1 3 1 1 1 3 3 1 3 3 3 3
38 75 29 50 99 5 44 33 77 71 3 57 57
 18 12
6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47 4 41 56 75 24 29 45 100 76 53 48 79 30 56 84 60 86
 18 12
2 9 6 7 12 8 1 1 2 2 1 1 7 11 9 7 8 11
43 40 3 7 5 55 95 1 19 61 41 15 24 10 52 72 47 55
 15 15
12 1 9 10 9 10 2 5 10 12 2 10 2 1 8
47 20 16 2 55 93 53 11 24 74 31 11 32 95 91
 16 16
8 7 9 6 9 16 11 13 13 15 8 5 4 4 9 4
16 45 45 34 51 58 89 73 28 4 85 54 18 56 97 44
 12 9
6 8 2 6 8 2 6 6 6 5 1 1
59 27 78 92 31 26 59 22 80 77 94 31
 2 2
2 2
7 12
 8 7
1 1 3 1 5 3 7 1
5 7 4 8 1 1 5 2
 13 11
6 1 9 9 10 7 3 8 1 4 11 4 11
48 19 90 85 2 46 38 99 41 67 79 1 27
 18 12
6 6 6 6 6 6 6 6 6 6 1 6 6 6 6 6 6 6
47 4 41 56 75 24 29 45 100 76 53 48 79 30 56 84 60 86
 18 12
2 9 6 7 12 8 1 1 2 2 1 1 7 11 9 7 8 11
43 40 3 7 5 55 95 1 19 61 41 15 24 10 52 72 12 55
 15 15
12 1 9 10 9 10 2 5 10 12 2 10 2 1 8
47 20 16 2 55 93 53 11 24 74 31 6 32 95 91
 12 9
6 8 3 6 8 2 6 6 6 5 1 1
59 27 78 92 31 26 59 22 80 77 94 31
 16 16
8 7 9 6 9 16 11 13 13 15 8 5 4 4 7 4
16 45 45 34 51 58 89 73 28 4 85 87 18 20 97 44
 12 9
6 8 3 6 8 2 6 6 9 5 1 1
59 27 78 92 31 26 59 22 65 77 94 31
 18 12
6 6 6 6 6 6 6 6 6 6 1 6 6 6 6 6 6 6
47 4 41 56 75 24 29 45 100 112 53 48 79 30 87 135 60 86
 16 16
8 7 9 6 9 16 11 13 13 15 8 7 4 4 7 4
16 45 45 34 51 58 89 73 28 4 85 87 18 20 97 44
 18 12
6 6 6 6 6 6 6 6 6 12 1 6 6 6 6 6 6 6
47 4 41 56 75 24 29 45 100 112 53 48 79 30 87 135 60 86
 18 12
6 6 6 6 6 6 6 6 6 12 1 3 6 6 6 6 6 6
47 4 41 56 75 24 29 45 100 112 53 48 79 30 87 135 60 86
 16 16
8 7 9 6 9 16 11 13 13 5 8 7 4 4 7 4
21 45 45 34 51 58 89 73 28 4 85 87 18 20 97 44
 12 9
6 1 3 6 6 2 6 6 9 5 2 1
59 27 78 92 31 26 59 22 65 77 94 31
 16 16
8 7 9 6 9 16 11 13 13 5 8 7 4 5 7 4
21 45 45 34 51 58 89 73 28 4 85 87 18 20 155 44
 18 12
6 3 6 6 6 6 6 6 6 12 1 3 6 6 6 6 6 6
47 4 41 56 75 24 29 6 100 112 53 48 79 30 87 135 60 87
 16 16
8 7 9 6 9 16 11 13 13 5 8 7 4 5 6 4
21 45 45 34 51 58 89 73 28 4 85 87 18 20 155 44
 18 12
6 3 6 6 6 6 6 6 6 12 1 3 6 6 6 6 6 6
47 4 41 56 75 24 29 10 100 112 53 48 79 30 87 135 60 87
 18 12
6 3 6 6 6 6 6 6 6 12 1 3 6 6 10 6 6 6
47 4 41 56 75 24 29 10 100 112 53 48 79 30 87 135 60 87
 18 12
6 3 6 6 6 6 6 6 6 12 1 3 6 6 10 6 6 6
47 4 41 56 75 24 29 10 100 112 53 48 79 30 87 135 10 87
 18 12
6 3 6 6 6 6 6 6 6 12 1 3 6 6 10 6 6 6
47 4 41 56 75 1 29 10 100 112 53 48 79 30 87 135 10 87
 18 12
6 3 1 6 6 6 6 6 6 12 1 3 6 6 10 6 6 6
47 4 41 56 75 0 29 10 100 112 53 48 79 30 87 135 10 87
 18 12
6 3 1 6 6 6 6 6 6 12 1 3 6 6 10 6 6 6
47 4 41 56 75 0 29 10 100 112 53 48 79 30 87 12 10 87
 18 12
6 3 1 6 6 6 6 6 6 12 1 3 6 6 10 6 6 6
47 4 41 56 75 0 29 10 100 112 53 3 79 30 87 12 10 87
 18 12
6 3 1 6 6 6 6 6 6 12 1 2 6 6 10 6 6 6
47 4 41 56 75 0 29 10 100 112 53 3 79 30 87 12 10 87
 18 12
6 3 1 6 6 6 6 6 6 12 1 2 9 6 10 6 6 6
47 4 41 56 75 0 29 10 100 112 53 3 79 30 87 12 10 87
 18 12
6 3 1 6 6 6 6 6 6 12 1 2 9 6 10 6 6 6
47 4 41 26 75 0 29 10 100 112 72 3 79 30 87 12 10 87
 14 6
2 3 6 6 6 2 5 3 5 5 5 6 5 5
56 41 19 81 19 32 99 37 97 20 142 44 19 79
 10 10
6 6 2 5 1 1 5 5 6 6
76 40 40 98 40 97 90 91 41 36
 18 12
6 6 6 6 6 6 6 6 6 6 7 6 6 6 6 6 6 6
47 4 41 56 75 16 29 45 100 76 53 48 79 30 56 84 60 86
 12 9
7 8 2 6 8 2 6 6 6 5 1 1
59 27 78 92 31 26 59 12 80 77 94 31
 8 7
1 1 3 1 5 3 7 1
5 14 4 8 1 3 5 2
 13 11
6 1 9 9 10 7 3 11 1 4 11 2 11
48 19 90 85 2 46 38 99 41 67 79 1 27
 13 5
3 1 3 1 1 1 3 3 1 3 3 3 3
38 75 29 50 99 5 44 33 77 71 3 57 57
 18 12
6 6 6 6 6 5 6 6 6 6 6 6 6 6 6 6 6 6
47 4 41 56 75 24 29 45 100 76 53 48 79 30 56 84 60 86
 12 9
6 8 2 6 8 2 6 6 6 5 1 1
59 27 78 92 31 21 59 22 80 77 94 31
 18 12
6 6 6 6 6 6 6 5 6 6 1 6 6 6 6 6 6 6
47 4 41 56 75 24 29 45 100 76 53 48 79 30 56 135 60 86
 19 2
1 1 1 2 2 1 1 2 1 2 2 2 2 2 2 2 1 2 2
92 91 86 3 32 40 25 14 51 10 53 35 28 51 60 73 51 22 66
 3 3
3 1 2
5 3 6
 16 16
8 7 9 6 9 16 11 13 13 15 8 5 4 4 9 4
16 45 45 34 51 58 89 73 28 4 85 54 18 20 97 44
 19 2
1 1 1 2 2 1 2 2 1 2 2 2 2 2 2 2 1 2 2
92 91 86 3 32 40 25 14 51 10 53 35 28 51 60 73 51 22 66
 2 2
1 2
7 12
 8 7
1 1 3 1 5 3 7 1
5 12 4 8 1 1 5 2
 18 12
6 6 6 6 6 6 6 6 6 6 1 6 6 6 6 6 6 6
47 4 41 56 75 24 29 45 100 76 53 48 79 30 56 135 60 86
 18 12
2 9 6 7 12 8 1 1 2 2 1 1 7 11 9 7 8 11
43 40 3 7 5 55 95 1 19 61 41 15 24 10 52 85 12 55
 16 16
8 7 9 6 9 16 11 13 13 15 8 5 4 4 9 4
16 45 45 34 51 58 89 73 28 4 85 87 18 20 97 44
 12 9
6 8 3 6 8 2 6 6 6 5 1 1
59 27 78 92 31 26 59 22 65 77 94 31
 18 12
6 6 6 6 6 6 6 6 6 6 1 6 6 6 6 6 6 6
47 4 41 56 75 24 29 45 100 112 53 48 79 30 56 135 60 86
 18 12
2 9 6 7 12 8 1 1 2 2 1 1 7 11 9 7 8 11
43 40 3 7 5 55 95 1 19 61 41 15 24 10 52 85 2 55
 12 9
6 1 3 6 8 2 6 6 9 5 1 1
59 27 78 92 31 26 59 22 65 77 94 31
 16 16
8 7 9 6 9 16 11 13 13 5 8 7 4 4 7 4
16 45 45 34 51 58 89 73 28 4 85 87 18 20 97 44
 12 9
6 1 3 6 6 2 6 6 9 5 1 1
59 27 78 92 31 26 59 22 65 77 94 31
 18 12
6 3 6 6 6 6 6 6 6 12 1 3 6 6 6 6 6 6
47 4 41 56 75 24 29 45 100 112 53 48 79 30 87 135 60 86
 16 16
8 7 9 6 9 16 11 13 13 5 8 7 4 4 7 4
21 45 45 34 51 58 89 73 28 4 85 87 18 20 155 44
 18 12
6 3 6 6 6 6 6 6 6 12 1 3 6 6 6 6 6 6
47 4 41 56 75 24 29 45 100 112 53 48 79 30 87 135 60 87
 18 12
6 3 1 6 6 6 6 6 6 12 1 3 6 6 10 6 6 6
47 4 41 56 75 1 29 10 100 112 53 48 79 30 87 135 10 87
 18 12
6 3 1 6 6 6 6 6 6 12 1 2 9 6 10 6 6 6
47 4 41 56 75 0 29 10 100 112 72 3 79 30 87 12 10 87
 13 3
3 1 3 1 1 1 3 3 1 3 3 3 3
38 75 29 50 99 5 44 33 45 71 3 24 57
 19 2
1 1 1 2 2 1 1 2 1 2 2 2 2 2 2 2 1 2 2
92 91 86 3 32 40 36 14 51 10 53 35 28 51 60 73 31 22 66
 2 1
1 1
6 11
 16 16
8 7 9 6 9 16 11 13 13 15 8 5 4 4 9 4
16 45 45 34 51 58 89 73 28 4 85 54 18 56 112 44
 19 2
1 1 1 2 2 1 1 2 1 2 2 2 2 2 2 2 1 2 2
92 91 86 3 32 40 25 14 51 10 53 26 28 51 60 73 51 22 66
 2 2
2 1
7 12
 3 3
3 2 2
5 3 6
 8 7
1 1 3 1 5 3 7 1
5 7 4 8 1 1 5 1
 13 11
6 1 9 9 10 7 3 8 1 4 11 4 11
48 19 90 85 2 46 38 99 41 65 79 1 27
 18 12
6 6 6 6 6 6 6 6 6 6 1 6 6 6 6 6 6 6
47 4 41 56 75 24 29 45 100 76 53 48 79 30 56 149 60 86
 18 12
2 9 6 7 12 8 1 2 2 2 1 1 7 11 9 7 8 11
43 40 3 7 5 55 95 1 19 61 41 15 24 10 52 72 12 55
 16 16
8 7 9 6 9 16 11 13 13 15 8 5 4 4 9 4
16 1 45 34 51 58 89 73 28 4 85 54 18 20 97 44
 12 9
6 8 3 6 8 2 6 6 6 5 1 1
59 27 78 92 31 26 59 22 90 77 94 31
 19 2
1 1 1 2 2 1 2 2 1 2 2 2 2 2 2 2 1 2 2
92 91 86 3 32 40 25 9 51 10 53 35 28 51 60 73 51 22 66
 8 7
1 1 4 1 5 3 7 1
5 12 4 8 1 1 5 2
 12 9
6 8 3 6 8 2 6 6 6 5 1 2
59 27 78 92 31 26 59 22 65 77 94 31
 18 12
6 6 6 6 6 6 6 6 6 6 1 1 6 6 6 6 6 6
47 4 41 56 75 24 29 45 100 112 53 48 79 30 56 135 60 86
 18 12
2 9 6 7 12 8 1 1 2 2 1 1 7 11 9 7 8 11
43 40 2 7 5 55 95 1 19 61 41 15 24 10 52 85 2 55
 12 9
6 8 3 6 8 2 6 6 9 5 1 1
59 27 78 92 31 31 59 22 65 77 94 31

0 10 13 0 47 0 3 38 338 425 33 189 182 96 0 7 0
 47
 3
 433
 33
 183
 202
 106
 7
 8
 20
 380
 30
 178
 80
 172
 49
 384
 259
 324
 276
 264
 75
 248
 237
 195
 241
 185
 148
 125
 124
 95
 94
 91
 61
 58
 38
 338
 372
 65
 10
 46
 37
 409
 101
 335
 0
 0
 178
 0
 0
 8
 380
 30
 178
 80
 380
 20
 49
 259
 80
 276
 264
 276
 125
 61
 3
 0
 0
 202
 0
 0
 3
 7
 20
 380
 30
 178
 80
 0
 7
 75
 380
 20
 49
