#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int i, j, n, m, t, q, ct = 0, sum = 0, flag = 0, minct = 1000000007;
  int p, k;
  cin >> n >> k;
  std::vector<long long int> v(n), v1;
  string s;
  for (i = 0; i < n; i++) cin >> v[i];
  cin >> s;
  for (i = 0; i < n; i++) {
    if (i > 0 && s[i] == s[i - 1]) {
      v1.push_back(v[i]);
      if (i + 1 > n - 1 || s[i] != s[i + 1]) {
        sort(v1.begin(), v1.end());
        p = v1.size();
        for (j = p - 1; j >= max(p - k, 0); j--) {
          sum += v1[j];
        }
        v1.clear();
      }
    } else {
      if (s[i] == s[i + 1])
        v1.push_back(v[i]);
      else
        sum += v[i];
    }
  }
  cout << sum;
  return 0;
}
