#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  long long arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  long long ans = 0;
  string str;
  cin >> str;
  vector<int> v;
  v.push_back(arr[0]);
  long long sum = 0;
  for (int i = 1; i < str.size(); i++) {
    if (str[i] == str[i - 1]) {
      v.push_back(arr[i]);
    } else {
      sort(v.begin(), v.end());
      for (int i = v.size() - 1, j = 0; i >= 0 && j < k; i--, j++) {
        sum += v[i];
      }
      v.clear();
      v.push_back(arr[i]);
    }
  }
  sort(v.begin(), v.end());
  for (int i = v.size() - 1, j = 0; i >= 0 && j < k; i--, j++) {
    sum += v[i];
  }
  cout << sum << endl;
}
