#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int Maxn = 2e5 + 10;
int num[Maxn];
bool ok[Maxn];
struct Node {
  int pos, val;
  Node(int x, int y) : pos(x), val(y){};
  bool operator<(const Node &a1) const { return val > a1.val; }
};
int main(void) {
  int n, k;
  cin >> n >> k;
  string s;
  for (int i = 0; i < n; ++i) cin >> num[i];
  cin >> s;
  memset(ok, true, sizeof(ok));
  priority_queue<Node> qu;
  for (int i = 0; i < n; ++i) {
    if (qu.empty())
      qu.push(Node(i, num[i]));
    else {
      int pos = qu.top().pos;
      if (s[pos] != s[i]) {
        while (!qu.empty()) qu.pop();
        qu.push(Node(i, num[i]));
      } else if (qu.size() < k)
        qu.push(Node(i, num[i]));
      else if (num[pos] < num[i]) {
        qu.pop();
        qu.push(Node(i, num[i]));
        ok[pos] = false;
      } else
        ok[i] = false;
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    if (ok[i]) ans += num[i];
  }
  cout << ans << endl;
  return 0;
}
