#include <bits/stdc++.h>
using namespace std;
long long n, k, sum = 0;
string s;
vector<long long> a, b;
int main() {
  cin >> n >> k;
  long long x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    b.push_back(x);
  }
  char tc, c;
  cin >> tc;
  a.push_back(b[0]);
  for (int i = 1; i < n; i++) {
    cin >> c;
    if (c == tc) {
      a.push_back(b[i]);
    } else {
      sort(a.rbegin(), a.rend());
      for (int j = 0; j < (a.size() < k ? a.size() : k); j++) {
        sum += a[j];
      }
      a.erase(a.begin(), a.end());
      a.push_back(b[i]);
    }
    tc = c;
  }
  sort(a.rbegin(), a.rend());
  for (int j = 0; j < (a.size() < k ? a.size() : k); j++) {
    sum += a[j];
  }
  cout << sum;
}
