#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-6;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, k;
long long a[maxn * 2];
long long ans[maxn * 2];
string s;
int main() {
  while (~scanf("%d%d", &n, &k)) {
    for (int i = 0; i < n; i++) {
      scanf("%lld", &a[i]);
    }
    cin >> s;
    int cnt = 1;
    long long sum = 0, sum1 = a[0];
    long long ans = 0;
    for (int i = 1; i <= s.size(); i++) {
      if (s[i] == s[i - 1]) {
        cnt++;
        sum1 += a[i];
      } else {
        if (cnt <= k) {
          ans += sum1;
          sum1 = 0;
          sum1 += a[i];
          cnt = 1;
        } else {
          sort(a + i - cnt, a + i);
          for (int j = i - 1, c = 1; j >= i - cnt && c <= k; j--, c++)
            ans += a[j];
          cnt = 1;
          sum1 = 0;
          sum1 += a[i];
        }
      }
    }
    printf("%lld\n", ans);
  }
}
