#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, 1, 1, 0, 0, -1, -1, -1};
int dy[] = {1, 0, -1, 1, -1, 1, 0, -1};
bool check(int r, int c) {
  return (r >= 1) && (r <= 8) && (c >= 1) && (c <= 8);
}
int main() {
  long long n, k;
  cin >> n >> k;
  vector<long long> v;
  for (long long i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  string s;
  cin >> s;
  long long ans = 0;
  vector<long long> v1;
  long long j;
  for (long long i = 0; i < n;) {
    priority_queue<long long> pq;
    pq.push(v[i]);
    for (j = i + 1; j < n; j++) {
      if (s[i] == s[j]) {
        pq.push(v[j]);
      } else {
        if (!pq.empty() && j == i + 1) {
          pq.pop();
          ans += pq.top();
        }
        break;
      }
    }
    long long count = 0;
    while (!pq.empty() && count < k) {
      ans += pq.top();
      pq.pop();
      count++;
    }
    i = j;
  }
  cout << ans << endl;
  return 0;
}
