#include <bits/stdc++.h>
using namespace std;
struct p {
  int a;
  int b;
} c[100000];
int num[100050];
bool cmp(p a, p b) { return a.b < b.b; }
int main() {
  int n, k;
  cin >> n >> k;
  int chose = 0;
  for (int i = 0; i < n; i++) scanf("%d", &c[i].a), num[c[i].a]++;
  for (int i = 0; i < n; i++) {
    scanf("%d", &c[i].b);
  }
  for (int i = 0; i <= k; i++) {
    if (num[i]) chose++;
  }
  sort(c, c + n, cmp);
  int i = 0;
  long long ans = 0;
  chose = k - chose;
  while (chose) {
    if (num[c[i].a] > 1) {
      chose--;
      num[c[i].a]--;
      ans += c[i].b;
    }
    i++;
  }
  cout << ans;
}
