#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  long long int sum = 0;
  for (int i = 0; i < n; i++) cin >> a[i];
  string s;
  cin >> s;
  int pre = 0;
  int cn = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == s[pre]) {
      cn++;
    } else {
      if (cn > k) {
        sort(a + pre, a + i);
        for (int j = i - 1; j >= i - k; j--) {
          sum += a[j];
        }
      } else {
        for (int j = pre; j < i; j++) {
          sum += a[j];
        }
      }
      pre = i;
      i--;
      cn = 0;
    }
  }
  if (cn == 1) {
    sum += a[n - 1];
  } else {
    if (cn > k) {
      sort(a + pre, a + n);
      for (int j = n - 1; j >= n - k; j--) {
        sum += a[j];
      }
    } else {
      for (int j = pre; j < n; j++) {
        sum += a[j];
      }
    }
  }
  cout << sum << endl;
  return 0;
}
