#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10, maxm = 1e6 + 10, inf = 0x3f3f3f3f;
const int mod = 998244353;
const double pi = acos(-1);
pair<int, int> a[maxn];
char s[maxn];
int b[maxn];
bool cmp(int a, int b) { return a > b; }
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].second;
  }
  cin >> (s + 1);
  for (int i = 1; i <= n; i++) {
    a[i].first = s[i] - 'a' + 1;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int r = i, t = 1;
    b[1] = a[i].second;
    while (r + 1 <= n && a[i].first == a[r + 1].first) b[++t] = a[++r].second;
    sort(b + 1, b + 1 + t, cmp);
    t = min(t, k);
    for (int j = 1; j <= t; j++) ans += b[j];
    i = r;
  }
  cout << ans << endl;
  return 0;
}
