#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<int> arr(n), v;
  for (long long i = 0; i < n; i++) cin >> arr[i];
  string s;
  cin >> s;
  long long ka = 0, sum = 0;
  for (long long i = 0; i < n;) {
    if (s[ka] == s[i]) {
      v.push_back(arr[i]);
      i++;
    }
    if (s[ka] != s[i] || i == n) {
      ka = i;
      if (v.size() <= k) {
        for (long long j : v) sum += j;
      } else {
        sort(v.begin(), v.end(), greater<int>());
        for (long long m = 0; m < k; m++) {
          sum += v[m];
        }
      }
      v.clear();
    }
  }
  cout << sum << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
