#include <bits/stdc++.h>
using namespace std;
long long a[200002];
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  string s;
  cin >> s;
  int count = 0;
  long long sum = 0;
  char check;
  long long tempsum = 0;
  for (int i = 0; i < s.length(); i++) {
    check = s[i];
    count = 0;
    while ((i + count) < s.length() && check == s[i + count]) count++;
    if (count > k) {
      tempsum = 0;
      sort(a + i, a + i + count);
      for (int z = 1; z <= k; z++) tempsum += a[i + count - z];
      sum += tempsum;
      i = i + count - 1;
      continue;
    }
    for (int p = 0; p < count; p++) {
      sum += a[i + p];
    }
    i = i + count - 1;
  }
  cout << sum;
}
