#include <bits/stdc++.h>
using namespace std;
int n, k, a[100005], b[100005], can[100005], p, done[100005], pp;
long long ans;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
  }
  for (int i = 1; i <= n; i++) {
    if (done[a[i]]) {
      p++;
      if (b[i] > done[a[i]]) {
        can[p] = done[a[i]];
        done[a[i]] = b[i];
      } else {
        can[p] = b[i];
      }
    } else {
      done[a[i]] = b[i];
    }
  }
  sort(can + 1, can + p + 1);
  for (int i = 1; i <= k; i++) {
    if (!done[i]) {
      pp++;
      ans += can[pp];
    }
  }
  printf("%lld\n", ans);
  return 0;
}
