#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int k;
  cin >> k;
  long long int sum = 0;
  long long int a[n + 1];
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  char str[300005];
  cin >> str;
  long long int i = 0;
  while (i < n) {
    long long int j = i, count = 0;
    while (str[j] == str[i]) {
      j++;
      count++;
    }
    if (count > k) {
      sort(a + i, a + j);
      i += (count - k);
    }
    while (i < j) {
      sum += a[i];
      i++;
    }
  }
  cout << sum;
  return 0;
}
