#include <bits/stdc++.h>
using namespace std;
int main() {
  long k, n;
  cin >> n >> k;
  long long A[n];
  for (long i = 0; i < n; i++) cin >> A[i];
  string s;
  cin >> s;
  long long dmg = 0;
  long i = 0;
  while (i < n) {
    long x = i + 1;
    while (x < n && s[x] == s[i]) x++;
    if (x - i <= k) {
      x--;
      for (long y = i; y <= x; y++) dmg += A[y];
    } else {
      x--;
      vector<long long> X;
      for (long y = i; y <= x; y++) X.push_back(A[y]);
      sort(X.begin(), X.end());
      long cnt = 0, oo = X.size() - 1;
      while (cnt < k) {
        dmg += X[oo];
        oo--;
        cnt++;
      }
    }
    i = x + 1;
  }
  cout << dmg;
  return 0;
}
