#include <bits/stdc++.h>
using namespace std;
long long n, k, l, h, s;
long long a[200200], b[200200];
char t[200200];
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> t[i];
  }
  for (int i = 1; i <= n;) {
    if (t[i] != t[i - 1]) {
      s = s + a[i];
      l = 1;
      i++;
    } else {
      if (l < k) {
        s = s + a[i];
        l++;
        i++;
      } else {
        h = 0;
        for (int j = i - k; j < i; j++) {
          s = s - a[j];
          h++;
          b[h] = a[j];
        }
        while (t[i] == t[i - 1]) {
          h++;
          b[h] = a[i];
          i++;
        }
        sort(b + 1, b + 1 + h);
        for (int j = h; j >= h - k + 1; j--) {
          s = s + b[j];
        }
      }
    }
  }
  cout << s;
}
