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.
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vadim
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        L solver = new L();
        solver.solve(1, in, out);
        out.close();
    }

    static class L {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.ni(), k = in.ni();
            int[] a = in.na(n);
            int[] b = in.na(n);
            int[] maxi = new int[k + 1];
            int[] max = new int[k + 1];
            P[] ps = new P[n];
            Arrays.fill(maxi, -1);
            for (int i = 0; i < n; i++) {
                ps[i] = new P(i, a[i], b[i]);
                if (max[a[i]] < b[i]) {
                    max[a[i]] = b[i];
                    maxi[a[i]] = i;
                }
            }
            Arrays.sort(ps);
            int rem = 0;
            for (int i = 1; i < k + 1; i++) {
                if (maxi[i] == -1) {
                    rem++;
                }
            }
            long ans = 0;
            for (P p : ps) {
                if (rem == 0) {
                    break;
                }
                if (maxi[p.job] == p.id)
                    continue;
                ans += p.b;
                rem--;
            }
            out.println(ans);

        }

        class P implements Comparable<P> {
            int id;
            int job;
            int b;

            public P(int id, int job, int b) {
                this.id = id;
                this.job = job;
                this.b = b;
            }

            public int compareTo(P o) {
                return Integer.compare(b, o.b);
            }

        }

    }

    static class FastScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public FastScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String ns() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int ni() {
            return Integer.parseInt(ns());
        }

        public int[] na(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = ni();
            return a;
        }

    }
}

