#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  int counter = 0;
  vector<long long int> dmg(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> dmg[i];
  }
  fflush(stdout);
  cin >> s;
  string modified = "";
  vector<int> v;
  int count = 0;
  modified += s[0];
  count = 1;
  for (int i = 1; i < s.size(); i++) {
    if (s[i] != modified[modified.size() - 1]) {
      v.push_back(count);
      count = 1;
      modified += s[i];
    } else {
      count += 1;
    }
  }
  v.push_back(count);
  priority_queue<long long int> pq;
  int index = 0;
  long long int ans = 0;
  for (int i = 0; i < modified.size(); i++) {
    pq = priority_queue<long long int>();
    count = 0;
    for (int j = 0; j < v[i]; j++) {
      pq.push(dmg[index++]);
    }
    while (!pq.empty() && count < k) {
      ans += pq.top();
      pq.pop();
      count++;
    }
  }
  cout << ans << endl;
  return 0;
}
