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.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.security.AccessControlException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
import java.util.stream.Stream;
public class _p001089L {
    static public void main(final String[] args) throws IOException {
        p001089L._main(args);
    }
//begin p001089L.java
static private class p001089L extends Solver{public p001089L(){nameIn="in/900/p001089L.in"
;singleTest=true;}int n;int k;int[]a;int[]b;protected void solve(){Map<Integer,List<Integer>>
map=mapi(a);long res=0;if(map.size()<k){PriorityQueue<Integer>pq0=new PriorityQueue<>
((x,y)->b[y]-b[x]);PriorityQueue<Integer>pq1=new PriorityQueue<>((x,y)->b[x]-b[y
]);map.entrySet().stream().filter(e->e.getValue().size()>1).forEach(e->{pq0.clear
();pq0.addAll(e.getValue());pq0.poll();pq1.addAll(pq0);});res=0;for(int i=0;i<k-
map.size();i++){res+=b[pq1.poll()];}}pw.println(res);}@Override public void readInput
()throws IOException{n=sc.nextInt();k=sc.nextInt();if(sc.hasNextLine()){sc.nextLine
();}a=Arrays.stream(sc.nextLine().trim().split("\\s+")).mapToInt(Integer::valueOf
).toArray();b=Arrays.stream(sc.nextLine().trim().split("\\s+")).mapToInt(Integer::valueOf
).toArray();solve();}static public void _main(String[]args)throws IOException{new
p001089L().run();}}
//end p001089L.java
//begin net/leksi/contest/Pair.java
static private class Pair<K,V>{private K k;private V v;public Pair(final K t,final
V u){this.k=t;this.v=u;}public K getKey(){return k;}public V getValue(){return v
;}}
//end net/leksi/contest/Pair.java
//begin net/leksi/contest/Solver.java
static private abstract class Solver{protected String nameIn=null;protected String
nameOut=null;protected boolean singleTest=false;protected boolean preprocessDebug
=false;protected boolean doNotPreprocess=false;protected PrintStream debugPrintStream
=null;protected Scanner sc=null;protected PrintWriter pw=null;final String SPACE
=" ";final String SPACES="\\s+";private void process()throws IOException{if(!singleTest
){int t=lineToIntArray()[0];while(t-->0){readInput();}}else{readInput();}}abstract
protected void readInput()throws IOException;protected int[]lineToIntArray()throws
IOException{return Arrays.stream(sc.nextLine().trim().split(SPACES)).mapToInt(Integer::valueOf
).toArray();}protected long[]lineToLongArray()throws IOException{return Arrays.stream
(sc.nextLine().trim().split(SPACES)).mapToLong(Long::valueOf).toArray();}protected
void run()throws IOException{boolean done=false;try{if(nameIn !=null&&new File(nameIn
).exists()){try(FileInputStream fis=new FileInputStream(nameIn);PrintWriter pw0=
select_output();){done=true;sc=new Scanner(fis);pw=pw0;process();}}}catch(IOException
ex){}catch(AccessControlException ex){}if(!done){try(PrintWriter pw0=select_output
();){sc=new Scanner(System.in);pw=pw0;process();}}}private PrintWriter select_output
()throws FileNotFoundException{if(nameOut !=null){return new PrintWriter(nameOut
);}return new PrintWriter(System.out);}public static Map<Integer,List<Integer>>mapi
(final int[]a){return IntStream.range(0,a.length).collect(()->new TreeMap<Integer
,List<Integer>>(),(res,i)->{if(!res.containsKey(a[i])){res.put(a[i],Stream.of(i)
.collect(Collectors.toList()));}else{res.get(a[i]).add(i);}},Map::putAll);}public
static Map<Long,List<Integer>>mapi(final long[]a){return IntStream.range(0,a.length
).collect(()->new TreeMap<Long,List<Integer>>(),(res,i)->{if(!res.containsKey(a[i
])){res.put(a[i],Stream.of(i).collect(Collectors.toList()));}else{res.get(a[i]).add
(i);}},Map::putAll);}public static<T>Map<T,List<Integer>>mapi(final T[]a){return
IntStream.range(0,a.length).collect(()->new TreeMap<T,List<Integer>>(),(res,i)->
{if(!res.containsKey(a[i])){res.put(a[i],Stream.of(i).collect(Collectors.toList(
)));}else{res.get(a[i]).add(i);}},Map::putAll);}public static<T>Map<T,List<Integer>>
mapi(final T[]a,Comparator<T>cmp){return IntStream.range(0,a.length).collect(()->
new TreeMap<T,List<Integer>>(cmp),(res,i)->{if(!res.containsKey(a[i])){res.put(a
[i],Stream.of(i).collect(Collectors.toList()));}else{res.get(a[i]).add(i);}},Map::putAll
);}public static Map<Integer,List<Integer>>mapi(final IntStream a){int[]i=new int
[]{0};return a.collect(()->new TreeMap<Integer,List<Integer>>(),(res,v)->{if(!res
.containsKey(v)){res.put(v,Stream.of(i[0]).collect(Collectors.toList()));}else{res
.get(v).add(i[0]);}i[0]++;},Map::putAll);}public static Map<Long,List<Integer>>mapi
(final LongStream a){int[]i=new int[]{0};return a.collect(()->new TreeMap<Long,List<Integer>>
(),(res,v)->{if(!res.containsKey(v)){res.put(v,Stream.of(i[0]).collect(Collectors
.toList()));}else{res.get(v).add(i[0]);}i[0]++;},Map::putAll);}public static<T>Map<T
,List<Integer>>mapi(final Stream<T>a,Comparator<T>cmp){int[]i=new int[]{0};return
a.collect(()->new TreeMap<T,List<Integer>>(cmp),(res,v)->{if(!res.containsKey(v)
){res.put(v,Stream.of(i[0]).collect(Collectors.toList()));}else{res.get(v).add(i
[0]);}},Map::putAll);}public static<T>Map<T,List<Integer>>mapi(final Stream<T>a)
{int[]i=new int[]{0};return a.collect(()->new TreeMap<T,List<Integer>>(),(res,v)
->{if(!res.containsKey(v)){res.put(v,Stream.of(i[0]).collect(Collectors.toList()
));}else{res.get(v).add(i[0]);}},Map::putAll);}public static List<int[]>listi(final
int[]a){return IntStream.range(0,a.length).mapToObj(i->new int[]{a[i],i}).collect
(Collectors.toList());}public static List<long[]>listi(final long[]a){return IntStream
.range(0,a.length).mapToObj(i->new long[]{a[i],i}).collect(Collectors.toList());
}public static<T>List<Pair<T,Integer>>listi(final T[]a){return IntStream.range(0
,a.length).mapToObj(i->new Pair<T,Integer>(a[i],i)).collect(Collectors.toList())
;}public static List<int[]>listi(final IntStream a){int[]i=new int[]{0};return a
.mapToObj(v->new int[]{v,i[0]++}).collect(Collectors.toList());}public static List<long
[]>listi(final LongStream a){int[]i=new int[]{0};return a.mapToObj(v->new long[]
{v,i[0]++}).collect(Collectors.toList());}public static<T>List<Pair<T,Integer>>listi
(final Stream<T>a){int[]i=new int[]{0};return a.map(v->new Pair<T,Integer>(v,i[0
]++)).collect(Collectors.toList());}protected String join(final int[]a){return Arrays
.stream(a).mapToObj(Integer::toString).collect(Collectors.joining(SPACE));}protected
String join(final long[]a){return Arrays.stream(a).mapToObj(Long::toString).collect
(Collectors.joining(SPACE));}protected<T>String join(final T[]a){return Arrays.stream
(a).map(v->Objects.toString(v)).collect(Collectors.joining(SPACE));}protected<T>
String join(final T[]a,final Function<T,String>toString){return Arrays.stream(a)
.map(v->toString.apply(v)).collect(Collectors.joining(SPACE));}protected<T>String
join(final Collection<T>a){return a.stream().map(v->Objects.toString(v)).collect
(Collectors.joining(SPACE));}protected<T>String join(final Collection<T>a,final Function<T
,String>toString){return a.stream().map(v->toString.apply(v)).collect(Collectors
.joining(SPACE));}protected<T>String join(final Stream<T>a){return a.map(v->Objects
.toString(v)).collect(Collectors.joining(SPACE));}protected<T>String join(final Stream<T>
a,final Function<T,String>toString){return a.map(v->toString.apply(v)).collect(Collectors
.joining(SPACE));}protected<T>String join(final IntStream a){return a.mapToObj(Integer::toString
).collect(Collectors.joining(SPACE));}protected<T>String join(final LongStream a
){return a.mapToObj(Long::toString).collect(Collectors.joining(SPACE));}protected
List<Integer>list(final int[]a){return Arrays.stream(a).mapToObj(Integer::valueOf
).collect(Collectors.toList());}protected List<Integer>list(final IntStream a){return
a.mapToObj(Integer::valueOf).collect(Collectors.toList());}protected List<Long>list
(final long[]a){return Arrays.stream(a).mapToObj(Long::valueOf).collect(Collectors
.toList());}protected List<Long>list(final LongStream a){return a.mapToObj(Long::valueOf
).collect(Collectors.toList());}protected<T>List<T>list(final Stream<T>a){return
a.collect(Collectors.toList());}protected<T>List<T>list(final T[]a){return Arrays
.stream(a).collect(Collectors.toList());}}
//end net/leksi/contest/Solver.java
}
