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