#include <bits/stdc++.h>
using namespace std;
inline void FAST_IO() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
int num[200005], val[200005];
string s;
signed main() {
  FAST_IO();
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> num[i];
  }
  cin >> s;
  int cnt = 0;
  val[cnt++] = num[0];
  long long res = 0;
  for (int i = 1; i < n; i++) {
    if (s[i] != s[i - 1]) {
      sort(val, val + cnt, greater<int>());
      for (int j = 0; j < k && j < cnt; j++) {
        res += val[j];
      }
      cnt = 0;
    }
    val[cnt++] = num[i];
  }
  sort(val, val + cnt, greater<int>());
  for (int j = 0; j < k && j < cnt; j++) {
    res += val[j];
  }
  cout << res << '\n';
  return 0;
}
