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.*;
import java.math.*;
import java.util.*;

public class Solution {
	/*
      InputReader class taken from https://gist.github.com/o-panda-o/32ce63499c05192827294eb529cc4fd0
      Which is publically available
    */
	static class InputReader {
    private boolean finished = false;

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1) {
            throw new InputMismatchException();
        }
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0) {
                return -1;
            }
        }
        return buf[curChar++];
    }

    public int peek() {
        if (numChars == -1) {
            return -1;
        }
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                return -1;
            }
            if (numChars <= 0) {
                return -1;
            }
        }
        return buf[curChar];
    }

    public int nextInt() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long nextLong() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public String nextString() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        StringBuilder res = new StringBuilder();
        do {
            if (Character.isValidCodePoint(c)) {
                res.appendCodePoint(c);
            }
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public boolean isSpaceChar(int c) {
        if (filter != null) {
            return filter.isSpaceChar(c);
        }
        return isWhitespace(c);
    }

    public static boolean isWhitespace(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private String readLine0() {
        StringBuilder buf = new StringBuilder();
        int c = read();
        while (c != '\n' && c != -1) {
            if (c != '\r') {
                buf.appendCodePoint(c);
            }
            c = read();
        }
        return buf.toString();
    }

    public String readLine() {
        String s = readLine0();
        while (s.trim().length() == 0) {
            s = readLine0();
        }
        return s;
    }

    public String readLine(boolean ignoreEmptyLines) {
        if (ignoreEmptyLines) {
            return readLine();
        } else {
            return readLine0();
        }
    }

    public BigInteger readBigInteger() {
        try {
            return new BigInteger(nextString());
        } catch (NumberFormatException e) {
            throw new InputMismatchException();
        }
    }

    public char nextCharacter() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        return (char) c;
    }

    public double nextDouble() {
        int c = read();
        while (isSpaceChar(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        double res = 0;
        while (!isSpaceChar(c) && c != '.') {
            if (c == 'e' || c == 'E') {
                return res * Math.pow(10, nextInt());
            }
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res *= 10;
            res += c - '0';
            c = read();
        }
        if (c == '.') {
            c = read();
            double m = 1;
            while (!isSpaceChar(c)) {
                if (c == 'e' || c == 'E') {
                    return res * Math.pow(10, nextInt());
                }
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                m /= 10;
                res += (c - '0') * m;
                c = read();
            }
        }
        return res * sgn;
    }

    public boolean isExhausted() {
        int value;
        while (isSpaceChar(value = peek()) && value != -1) {
            read();
        }
        return value == -1;
    }

    public String next() {
        return nextString();
    }

    public SpaceCharFilter getFilter() {
        return filter;
    }

    public void setFilter(SpaceCharFilter filter) {
        this.filter = filter;
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
    public int[] nextIntArray(int n){
        int[] array=new int[n];
        for(int i=0;i<n;++i)array[i]=nextInt();
        return array;
    }
    public int[] nextSortedIntArray(int n){
        int array[]=nextIntArray(n);
        Arrays.sort(array);
        return array;
    }
    public int[] nextSumIntArray(int n){
        int[] array=new int[n];
        array[0]=nextInt();
        for(int i=1;i<n;++i)array[i]=array[i-1]+nextInt();
        return array;
    }
    public long[] nextLongArray(int n){
        long[] array=new long[n];
        for(int i=0;i<n;++i)array[i]=nextLong();
        return array;
    }
    public long[] nextSumLongArray(int n){
        long[] array=new long[n];
        array[0]=nextInt();
        for(int i=1;i<n;++i)array[i]=array[i-1]+nextInt();
        return array;
    }
    public long[] nextSortedLongArray(int n){
        long array[]=nextLongArray(n);
        Arrays.sort(array);
        return array;
    }
}
    public static final long MOD = 1000000007L;
    static boolean[] marked;
	public static void main(String[] args) {
		InputReader sc=new InputReader(System.in);
		PrintWriter out=new PrintWriter(new BufferedOutputStream(System.out), true);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int[] b=new int[n];
		TreeSet<Integer> b1=new TreeSet<>();
	    Pair[] a = new Pair[100005];
	    for(int i=0;i<n;i++){
	        b[i]=sc.nextInt();
	        b1.add(b[i]);
	        a[b[i]] = new Pair();
	    }
	    for(int i=0;i<n;i++){
	        a[b[i]].a.add(sc.nextInt());
	    }
	    
	    List<Integer> c=new ArrayList<>();
	    for(int i=0;i<100005;i++){
	        if(a[i]==null) continue;
	        Collections.sort(a[i].a);
	        for(int j=0;j<a[i].a.size()-1;j++){
	            c.add(a[i].a.get(j));
	        }
	    }
	    Collections.sort(c);
	    //out.println(c);
	    long ans=0;
	    for(int i=0;i<k-b1.size();i++){
	        ans+=c.get(i);
	    }
	    out.println(ans);
	}
	static class Graph{
	    public int v;
	    public LinkedList<Integer>[] adj;
	    public Graph(int n){
	        v=n;
	        adj=new LinkedList[n];
	        for(int i=0;i<n;i++){
	            adj[i] = new LinkedList<>();
	        }
	    }
	    public void addEdge(int u, int v){
	        adj[u].add(v);
	        adj[v].add(u);
	    }
	}
	static int gcd(int a, int b) {
      if (b == 0) 
        return a; 
      return gcd(b, a % b);  
    } 
	static boolean[] pr;
	static List<Integer> primes;
	static void sieve(){
	    pr=new boolean[100001];
	    primes=new ArrayList<>();
	    Arrays.fill(pr,true);
	    pr[0]=pr[1]=false;
	    int n=100000;
	    for(int p = 2; p*p <=n; p++) { 
            if(pr[p] == true) { 
                for(int i = p*2; i <= n; i += p) 
                    pr[i] = false; 
            } 
        }  
        for(int i = 2; i <= n; i++) {
            if(pr[i] == true) 
                primes.add(i); 
        } 
	}
	static class Pair implements Comparable<Pair>{
		List<Integer> a;
		public Pair(){
			a=new ArrayList<>();
		}
		public int compareTo(Pair p){
		    return p.a.size()-a.size();
		}
	}
}