#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n, k;
  cin >> n >> k;
  long long arr[n];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  string str;
  cin >> str;
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    long long alpha = 0;
    for (long long j = i + 1; j < n; j++) {
      if (str[i] == str[j])
        alpha++;
      else
        break;
    }
    sort(arr + i, arr + i + alpha + 1);
    if (alpha + 1 >= k)
      for (long long j = 0; j < k; j++) {
        ans += arr[i + alpha - j];
      }
    else
      for (long long j = i; j < n; j++) {
        if (str[i] == str[j])
          ans += arr[j];
        else
          break;
      }
    i += alpha;
  }
  cout << ans;
  return 0;
}
