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.
//package math_codet;

//Kuch ho naa ho, code sundar hona chahiye.............

import java.io.*;
import java.util.*;

public class lets_do {
    InputReader in;
    PrintWriter out;
    Helper_class h;
    final long mod = (long)1e9 + 7;
    final int MAXN = 1005;
    final int MAX_Ai = 100005;

    public static void main(String[] args) throws java.lang.Exception{
        new lets_do().run();
    }
    void run() throws Exception{
        in=new InputReader();
        out = new PrintWriter(System.out);
        h = new Helper_class();
        int t = 1;
        while(t-->0)
            solve();
        out.flush();
        out.close();
    }
    void solve(){
        int n = h.ni();
        int k = h.ni();
        int[] arr = new int[n];
        long[] time = new long[n];
        int i = 0;
        for(i = 0; i < n; i++)
            arr[i] = h.ni();
        int[] ind = new int[k + 1];
        long[] max = new long[k + 1];
        for(i = 0; i < n; i++){
            time[i] = h.nl();
            if(time[i] > max[arr[i]]){
                max[arr[i]] = time[i];
                ind[arr[i]] = i + 1;
            }
        }
        TreeSet<Integer> tset = new TreeSet<Integer>();
        for(i = 1; i <= k; i++){
            if(ind[i] > 0)
                tset.add(ind[i]);
        }
        long[] arr1 = new long[n - tset.size()];
        int p = 0;
        for(i = 1; i <= n; i++){
            if(!tset.contains(i))
                arr1[p++] = time[i - 1];
        }
        Arrays.sort(arr1);
        long sum = 0;
        for(i = 0; i < k - tset.size(); i++)
            sum += arr1[i];
        h.pn(sum);
    }
    static final Comparator<Pair> com=new Comparator<Pair>(){
        public int compare(Pair a, Pair b){
            int xx = Long.compare(a.d, b.d);
            if(xx == 0){
                int xxx = Long.compare(a.h, b.h);
                if(xxx == 0)
                    return Integer.compare(a.ind, b.ind);
                else
                    return xxx;
            }
            else
                return xx;
        }
    };
    class Pair{
        long d;
        long h;
        int ind;
        Pair(long p, long q, int i){
            d = p;
            h = q;
            ind = i;
        }
    }
    class Edge{
        int u , v;
        Edge(int a, int b){
            u = a;
            v = b;
        }
        int other(int x) {
            return u ^ v ^ x;
        }
    }
    class Vertex{
        int id;
        long f;
        Vertex parent;
        ArrayList<Vertex> children;
        ArrayList<Ticket> tickets;
        Vertex(int i){
            id = i;
            children = new ArrayList<>();
            tickets = new ArrayList<>();
        }
    }
    class Ticket{
        int k;
        long w;
        Ticket(int kk, long ww){
            k = kk;
            w = ww;
        }
    }
    class Helper_class{
        long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
        int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
        int bitcount(long n){return (n==0)?0:(1+bitcount(n&(n-1)));}
        void p(Object o){out.print(o);}
        void pn(Object o){out.println(o);}
        void pni(Object o){out.println(o);out.flush();}
        String n(){return in.next();}
        String nln(){return in.nextLine();}
        int ni(){return Integer.parseInt(in.next());}
        long nl(){return Long.parseLong(in.next());}
        double nd(){return Double.parseDouble(in.next());}

        long mul(long a,long b){
            if(a>=mod)a%=mod;
            if(b>=mod)b%=mod;
            a*=b;
            if(a>=mod)a%=mod;
            return a;
        }
        long modPow(long a, long p){
            long o = 1;
            while(p>0){
                if((p&1)==1)o = mul(o,a);
                a = mul(a,a);
                p>>=1;
            }
            return o;
        }
        long add(long a, long b){
            if(a>=mod)a%=mod;
            if(b>=mod)b%=mod;
            if(b<0)b+=mod;
            a+=b;
            if(a>=mod)a-=mod;
            return a;
        }
    }

    class InputReader{
        BufferedReader br;
        StringTokenizer st;
        public InputReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public InputReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next(){
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String str = "";
            try{
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }
            return str;
        }
    }
}  