#include <bits/stdc++.h>
using namespace std;
vector<int> v;
vector<int> arr[26];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, k;
  cin >> n >> k;
  int num;
  for (int i = 0; i < n; i++) {
    cin >> num;
    v.push_back(num);
  }
  string s;
  cin >> s;
  int ctr = 1;
  for (int i = 1; i < s.size(); i++) {
    if (s[i] == s[i - 1])
      ctr++;
    else {
      if (ctr > 1 && ctr > k) {
        sort(v.begin() + (i - ctr), v.begin() + i);
        reverse(v.begin() + (i - ctr), v.begin() + i);
      }
      ctr = 1;
    }
  }
  if (ctr > 1 && ctr > k) {
    sort(v.begin() + (n - ctr), v.begin() + n);
    reverse(v.begin() + (n - ctr), v.begin() + n);
  }
  long long ans = v[0];
  ctr = 1;
  for (int i = 1; i < n; i++) {
    if (s[i] == s[i - 1]) {
      ctr++;
      if (ctr <= k) ans += v[i];
    } else {
      ctr = 1;
      ans += v[i];
    }
  }
  cout << ans << endl;
}
