#include <bits/stdc++.h>
using namespace std;
bool comp(long long a, long long b) { return a > b; }
void solve() {
  long long n, k, sum = 0, k1;
  cin >> n >> k;
  string s;
  long long ar[n], cnt = 1, i, j = 0;
  vector<long long> br(n, 0);
  for (i = 0; i < n; i++) cin >> ar[i];
  cin >> s;
  for (i = 0; i < n; i++) {
    if (s[i] == s[i + 1])
      cnt++;
    else {
      br[j] = cnt;
      j += cnt;
      cnt = 1;
    }
  }
  for (i = 0; i < n;) {
    if (br[i] > k) sort(ar + i, ar + i + br[i], comp);
    i += br[i];
  }
  for (i = 0; i < n; i++) {
    if (br[i] > k) {
      k1 = k;
      j = i;
      while (k1--) sum += ar[j++];
      i += br[i] - 1;
    } else
      sum += ar[i];
  }
  cout << sum;
  return;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  long long t = 1;
  while (t--) solve();
  return 0;
}
