#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1, u, j;
  for (u = 1; u <= t; u++) {
    long long int n, i, j, f_ans = 0, m, zs = 0, os = 0, zt = 0, ot = 0, k;
    cin >> n >> k;
    long long int A[n];
    for (i = 0; i < n; i++) cin >> A[i];
    string s;
    cin >> s;
    vector<vector<long long int>> solve;
    vector<long long int> current = {A[0]};
    for (i = 1; i < n; i++) {
      if (s[i] != s[i - 1]) {
        sort(current.begin(), current.end(), greater<long long int>());
        solve.push_back(current);
        current.clear();
      }
      current.push_back(A[i]);
    }
    sort(current.begin(), current.end(), greater<long long int>());
    solve.push_back(current);
    for (i = 0; i < solve.size(); i++) {
      current = solve[i];
      ot = current.size();
      for (j = 0; j < min(ot, k); j++) f_ans += current[j];
    }
    cout << f_ans << endl;
  }
}
