#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  long long int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  string str;
  cin >> str;
  priority_queue<long long int> pq;
  long long int ans = 0;
  int temp = 0;
  int flag = 0;
  for (int i = 0; i <= n - 1; i++) {
    if (i == n - 1) {
      if (str[n - 1] == str[n - 2]) {
        pq.push(arr[n - 1]);
        flag = 1;
      } else {
        ans += arr[n - 1];
      }
    } else {
      if (str[i] == str[i + 1]) {
        pq.push(arr[i]);
        flag = 1;
      } else {
        if (flag == 1) {
          pq.push(arr[i]);
          int j = 0;
          while (j < k && pq.size() != 0) {
            ans += pq.top();
            pq.pop();
            j++;
          }
          flag = 0;
          while (pq.size() != 0) {
            pq.pop();
          }
        } else {
          ans += arr[i];
        }
      }
    }
  }
  int j = 0;
  while (j < k && (pq.size() != 0)) {
    ans += pq.top();
    pq.pop();
    j++;
  }
  cout << ans;
  return 0;
}
