#include <bits/stdc++.h>
using namespace std;
bool cmp(long long a, long long b) { return (a > b); }
long long a[200010];
int n, k;
char s[200010];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i <= n - 1; i++) scanf("%lld", &a[i]);
  scanf("%s", s);
  int i = 0;
  long long ans = 0;
  while (i <= n - 1) {
    if (i != n - 1 && s[i] == s[i + 1]) {
      vector<long long> vec;
      int j = i + 1;
      vec.push_back(a[i]);
      vec.push_back(a[i + 1]);
      while (j < n - 1 && s[j] == s[j + 1]) {
        j++;
        vec.push_back(a[j]);
      }
      sort(vec.begin(), vec.end(), cmp);
      for (int ii = 0; ii <= min(k - 1, (int)(vec.size() - 1)); ii++)
        ans += vec[ii];
      i = j + 1;
      if (i > n - 1) break;
    } else {
      ans += a[i];
      i++;
    }
  }
  printf("%lld\n", ans);
  return (0);
}
