#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;
const int MAX = 0x7fffffff;
const int MIN = 0x80000000;
int n, k;
struct node {
  int num, index;
  bool friend operator<(node a, node b) { return a.num > b.num; }
};
node a[N];
char ch[N];
int pos[N] = {0};
int dp[N] = {0};
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i].num);
    a[i].index = i;
  }
  scanf("%s", ch);
  long long sum = 0;
  sort(a, a + n);
  pos[0] = 0;
  for (int i = 1; i < n; i++) {
    if (ch[i] == ch[i - 1])
      pos[i] = pos[i - 1];
    else
      pos[i] = i;
  }
  for (int i = 0; i < n; i++) {
    if (dp[pos[a[i].index]] < k) {
      sum += a[i].num;
      dp[pos[a[i].index]]++;
    }
  }
  cout << sum << endl;
}
