#include <bits/stdc++.h>
using namespace std;
const int inf = 100000000;
const double eps = 10e-6;
bool rcmp(int a, int b) { return a > b; }
int main() {
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  string s;
  cin >> s;
  long long d;
  int c;
  long long dmg = 0;
  int i = 0;
  int j = 0;
  while (i < n) {
    c = s[i];
    d = a[i];
    j = i + 1;
    while (j < n && s[j] == c) {
      d += a[j];
      ++j;
    }
    if (-i + j <= k) {
      dmg += d;
    } else {
      sort(a.begin() + i, a.begin() + j, rcmp);
      for (int p = i; p < i + k; ++p) {
        dmg += a[p];
      }
    }
    i = j;
  }
  cout << dmg << '\n';
}
