#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, i, j, x;
  cin >> n >> k;
  vector<long long> v;
  for (i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
  }
  string s;
  cin >> s;
  s += '-';
  char p = s[0];
  vector<long long> tmp;
  long long ans = 0;
  for (i = 0; i < s.length(); i++) {
    if (s[i] == p) {
      tmp.push_back(v[i]);
    } else {
      p = s[i];
      if (tmp.size() > k) {
        sort(tmp.begin(), tmp.end(), greater<long long>());
        for (j = 0; j < k; j++) {
          ans += tmp[j];
        }
      } else {
        for (auto it : tmp) {
          ans += it;
        }
      }
      tmp.clear();
      tmp.push_back(v[i]);
    }
  }
  cout << ans << endl;
  return 0;
}
