#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k;
  cin >> n >> k;
  long long int tans = 0;
  vector<pair<long long int, long long int> > points;
  std::vector<long long int> vals;
  for (int i = 0; i < n; ++i) {
    long long int x;
    cin >> x;
    vals.push_back(x);
    tans += x;
  }
  string s;
  cin >> s;
  char c1 = s[0];
  int start = 0;
  int cnt = 1;
  int end = 0;
  for (int i = 1; i < n; ++i) {
    if (s[i] == c1) cnt++;
    if (s[i] != c1) {
      if (cnt > k) points.push_back(make_pair(start, i - 1));
      start = i;
      c1 = s[i];
      cnt = 1;
    }
  }
  if (cnt > k) points.push_back(make_pair(start, n - 1));
  for (int i = 0; i < points.size(); ++i) {
    long long int p1 = points[i].first;
    long long int p2 = points[i].second;
    std::vector<long long int> vv;
    for (int j = p1; j <= p2; ++j) vv.push_back(vals[j]);
    sort(vv.begin(), vv.end());
    for (int j = 0; j < vv.size() - k; ++j) tans -= vv[j];
  }
  cout << tans << endl;
}
