#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int k, n, first = -1, sum = 0;
  cin >> n >> k;
  long long int a[n];
  long long int ans = 0;
  for (long long int i = 0; i < n; ++i) cin >> a[i];
  string s;
  cin >> s;
  int flag = 0;
  for (long long int i = 0; i < n; ++i) {
    if (s[i] == s[i + 1]) {
      if (first == -1) first = i;
      flag = 1;
    } else if (flag) {
      sort(a + first, a + i + 1);
      long long int mini = min(k, i - first + 1);
      for (long long int j = 0; j < mini; ++j) {
        sum += a[i - j];
      }
      flag = 0;
      first = -1;
    } else {
      sum += a[i];
    }
  }
  cout << sum << endl;
  return 0;
}
