#include <bits/stdc++.h>
const long long INF = (long long)1e18 + 2;
using namespace std;
void solve();
void fastIO() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  fastIO();
  solve();
}
void solve() {
  int n, k;
  cin >> n >> k;
  long long int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  string s;
  cin >> s;
  vector<int> vec;
  vec.push_back(a[0]);
  char pre = s[0];
  long long int ans = 0;
  for (int i = 1; i < n; i++) {
    if (s[i] == pre)
      vec.push_back(a[i]);
    else {
      sort(vec.begin(), vec.end());
      int cnt = 0;
      for (int j = vec.size() - 1; j >= 0; j--) {
        ans += vec[j];
        cnt++;
        if (cnt == k) break;
      }
      pre = s[i];
      vec.clear();
      vec.push_back(a[i]);
    }
  }
  sort(vec.begin(), vec.end());
  int cnt = 0;
  for (int j = vec.size() - 1; j >= 0; j--) {
    ans += vec[j];
    cnt++;
    if (cnt == k) break;
  }
  cout << ans;
}
