#include <bits/stdc++.h>
using namespace std;
int main() {
  long long dmg = 0;
  int n, k;
  cin >> n >> k;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  string s;
  cin >> s;
  int i = 0;
  while (i < n) {
    vector<long long> v;
    int j = i;
    while (s[j] == s[i]) {
      v.push_back(a[j]);
      j++;
    }
    sort(v.begin(), v.end());
    int m = v.size();
    if (m <= k) {
      for (i = 0; i < m; i++) {
        dmg = dmg + v.back();
        v.pop_back();
      }
    } else {
      for (i = 0; i < k; i++) {
        dmg = dmg + v.back();
        v.pop_back();
      }
    }
    v.clear();
    i = j;
  }
  cout << dmg;
}
