#include <bits/stdc++.h>
using namespace std;
int n, k;
long long input[200010], sum;
char s[200010];
priority_queue<long long> pq;
int main() {
  int i, j, l;
  scanf("%d %d", &n, &k);
  for (i = 1; i <= n; i++) scanf("%I64d", &input[i]);
  scanf("%s", s);
  for (i = n; i >= 1; i--) s[i] = s[i - 1];
  for (i = 1; i <= n; i++) {
    j = i;
    while (!pq.empty()) pq.pop();
    while (s[i] == s[j] && j <= n) {
      pq.push(input[j]);
      j++;
    }
    i = j - 1;
    l = min((int)pq.size(), k);
    for (j = 1; j <= l; j++) {
      sum += pq.top();
      pq.pop();
    }
  }
  printf("%I64d", sum);
}
