#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = (int)2e5 + 5;
long long n, m, a[MAXN], k;
char s[MAXN], now;
priority_queue<long long, vector<long long>, greater<long long> > q;
int main() {
  cin >> n >> k;
  for (int i = (1); i <= (n); i++) cin >> a[i];
  scanf("%s", s + 1);
  long long ans = 0;
  now = s[1];
  for (int i = 1; s[i]; i++) {
    if (s[i] == now) {
      if (q.size() < k)
        q.push(a[i]);
      else {
        long long temp = q.top();
        q.pop();
        temp = (temp) > (a[i]) ? (temp) : (a[i]);
        q.push(temp);
      }
    } else {
      while (!q.empty()) {
        ans += q.top();
        q.pop();
      }
      now = s[i];
      q.push(a[i]);
    }
  }
  while (!q.empty()) {
    ans += q.top();
    q.pop();
  }
  printf("%lld\n", ans);
  return 0;
}
