#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  long long x, y;
  cin >> n >> k;
  long long A[n + 1];
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  string s;
  cin >> s;
  int l = 1;
  long long tt = A[0];
  long long sum = 0;
  long long maxx = tt;
  for (int i = 0; i < n; i++) {
    int j = i;
    priority_queue<long long> q;
    for (j = i; s[j] == s[j + 1] && j < n - 1; j++) {
      q.push(A[j]);
    }
    i = j;
    q.push(A[i]);
    int l = 0;
    while (l < k && q.size() > 0) {
      l++;
      sum += q.top();
      q.pop();
    }
  }
  cout << sum;
}
