#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  string s;
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  cin >> s;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    if (i < n - 1 && s[i] == s[i + 1]) {
      vector<int> ttt;
      ttt.push_back(a[i]);
      i++;
      while (i < n && s[i] == s[i - 1]) ttt.push_back(a[i]), i++;
      i--;
      sort(ttt.rbegin(), ttt.rend());
      for (int q = 0; q < (int)ttt.size(); q++) {
        if (q + 1 > k) break;
        sum += ttt[q];
      }
    } else
      sum += a[i];
  }
  cout << sum << "\n";
}
