#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const long long int inf = 1e18;
void solve() {
  long long int n, k;
  cin >> n >> k;
  vector<long long int> a(n);
  for (auto &x : a) cin >> x;
  long long int ans = 0;
  string s;
  cin >> s;
  s += '#';
  char cur = s[0];
  long long int cnt = 0;
  long long int i = 0;
  while (i < n) {
    priority_queue<long long int> pq;
    while (i < n and cur == s[i]) cnt++, pq.push(a[i]), i++;
    cnt = min(cnt, k);
    while (cnt--) ans += pq.top(), pq.pop();
    cur = s[i];
    cnt = 0;
  }
  cout << ans;
}
void debug(long long int tt) {}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
}
