#include <bits/stdc++.h>
using namespace std;
int ar[200005], n, k, pre[2 * 200005];
string s;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d ", ar + i);
  }
  long long ans = 0;
  cin >> s;
  char last = '#';
  int j, i;
  for (i = j = 0; i < n; ++i) {
    if (s[i] == last) continue;
    if (last == '#') {
      last = s[i];
      j = 0;
      continue;
    }
    sort(ar + j, ar + i);
    for (int k1 = i - 1; k1 >= max(j, i - k); k1--) {
      ans += ar[k1];
    }
    j = i;
    last = s[i];
  }
  sort(ar + j, ar + i);
  for (int k1 = i - 1; k1 >= max(j, i - k); k1--) {
    ans += ar[k1];
  }
  cout << ans;
  return 0;
}
