#include <bits/stdc++.h>
using namespace std;
int Gcd(int a, int b) {
  if (b == 0) return a;
  return Gcd(b, a % b);
}
int Lcm(int a, int b) { return a / Gcd(a, b) * b; }
inline long long read() {
  long long f = 1, x = 0;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int maxn = 1e6 + 10;
int a[maxn];
vector<int> g[26];
char s[maxn];
int main() {
  int n = read(), k = read();
  for (int i = 0; i < n; i++) {
    a[i] = read();
  }
  scanf("%s", s);
  int cnt = 1;
  vector<int> res;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == s[i + 1]) {
      cnt++;
    } else {
      for (int j = 0; j < cnt; j++) {
        res.push_back(a[i - j]);
      }
      sort(res.begin(), res.end());
      int len = res.size();
      for (int i = len - 1, c = 1; i >= 0 && c <= k; i--, c++) {
        ans += res[i];
      }
      res.clear();
      cnt = 1;
    }
  }
  cout << ans << endl;
  return 0;
}
