#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, K, a;
  cin >> n >> K;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    cin >> a;
    v.push_back(a);
  }
  string s;
  cin >> s;
  long long t = 0;
  for (int i = 0, j = 0; i < n;) {
    i = j;
    while (j < n && s[i] == s[j]) {
      j++;
    }
    sort(v.begin() + i, v.begin() + j);
    reverse(v.begin() + i, v.begin() + j);
    for (int k = i; k < min(j, i + K); k++) {
      t += v[k];
    }
  }
  cout << t << endl;
}
