#include <bits/stdc++.h>
using namespace std;
template <typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  string s;
  cin >> s;
  bool isrow = false;
  long long ans = 0;
  for (int i = 0, j = 0; i < n; i = j) {
    while (j < n && s[i] == s[j]) j++;
    sort(a.begin() + i, a.begin() + j);
    reverse(a.begin() + i, a.begin() + j);
    for (int l = i; l < min(j, i + k); l++) {
      ans += a[l];
    }
  }
  cout << ans << endl;
}
