#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 1;
long long a[maxn];
struct node {
  long long x, y;
} s[maxn];
bool cmp(node a, node b) {
  if (a.x == b.x)
    return a.y > b.y;
  else
    return a.x < b.x;
}
int main() {
  long long k, n, cnt = 0, sum = 0;
  long long ans = 0;
  scanf("%lld%lld", &k, &n);
  for (long long i = 0; i < k; i++) {
    scanf("%lld", &s[i].x);
  }
  for (long long i = 0; i < k; i++) {
    scanf("%lld", &s[i].y);
  }
  sort(s, s + k, cmp);
  for (long long i = 1; i < k; i++) {
    if (s[i].x != s[i - 1].x) sum++;
    if (s[i].x == s[i - 1].x) a[cnt++] = s[i].y;
  }
  sort(a, a + cnt);
  sum = n - sum - 1;
  for (long long i = 0; i < sum; i++) {
    ans += a[i];
  }
  printf("%lld\n", ans);
}
