#include <bits/stdc++.h>
using namespace std;
long long n, m, t, caseno, k;
vector<long long> V;
long long a[200005];
char s[200005];
int main() {
  long long i, j;
  scanf("%lld%lld", &n, &k);
  for (i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  scanf("%s", &s);
  long long res = 0;
  for (i = 0; i <= n - 1; i++) {
    j = i;
    V.clear();
    while (j < n && s[i] == s[j]) {
      V.push_back(a[j + 1]);
      j++;
    }
    sort(V.begin(), V.end(), greater<long long>());
    long long d = V.size();
    d = min(d - 1, k - 1);
    long long f;
    for (f = 0; f <= d; f++) {
      res += V[f];
    }
    i = j - 1;
  }
  printf("%lld\n", res);
  return 0;
}
