#include <bits/stdc++.h>
using namespace std;
long long arr[300000];
int main() {
  long long n, m;
  scanf("%lld %lld", &n, &m);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &arr[i]);
  }
  string s;
  cin >> s;
  long long len = s.size();
  long long ans = 0;
  for (long long i = 0; i < len; i++) {
    char c = s[i];
    priority_queue<long long> q;
    long long j = i;
    while (s[j] == c && j < len) {
      q.push(arr[j + 1]);
      i = j;
      j++;
    }
    long long temp = m;
    while (temp > 0 && !q.empty()) {
      long long keep = q.top();
      ans += keep;
      q.pop();
      temp--;
    }
  }
  cout << ans << endl;
  return 0;
}
