#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  string s;
  cin >> s;
  int i = 0;
  long long ans = 0;
  while (i < n) {
    priority_queue<long long> pq;
    int j = i;
    int c = 0;
    while (j < n && s[j] == s[i]) {
      pq.push(a[j]);
      j++;
      c++;
    }
    long long now = 0;
    int tot = 0;
    while (!pq.empty() && tot < k) {
      now += pq.top();
      pq.pop();
      tot++;
    }
    ans += now;
    i = j;
  }
  cout << ans;
}
