#include <bits/stdc++.h>
using namespace std;
int const N = 3e5 + 2;
int n, k, v[N];
int main() {
  string s;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) scanf("%d", v + i);
  cin >> s;
  long long an = 0;
  for (int i = 0; i < n; ++i) {
    vector<int> curr;
    char x = s[i];
    curr.push_back(v[i]);
    while (i < n - 1 && s[i + 1] == x) {
      ++i;
      curr.push_back(v[i]);
    }
    sort(curr.begin(), curr.end());
    reverse(curr.begin(), curr.end());
    for (int j = 0; j < curr.size() && j < k; ++j)
      an = (long long)an + (long long)curr[j];
  }
  cout << an;
}
