#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  long long int n, k, d = 0;
  cin >> n >> k;
  long long int w, m;
  w = k;
  string s;
  vector<long long int> g(n);
  for (int i = 0; i < n; i++) {
    cin >> g[i];
  }
  cin >> s;
  for (int i = 0; i < n; i++) {
    w = k;
    if (s[i] == s[i + 1]) {
      int j = i;
      vector<pair<char, long long int>> v;
      for (m = j; s[m] == s[m + 1]; m++) {
        v.push_back(make_pair(s[m], g[m]));
      }
      v.push_back(make_pair(s[m], g[m]));
      sort(v.rbegin(), v.rend());
      long long int h = v.size();
      for (int u = 0; u < min(w, h); u++) {
        d += v[u].second;
      }
      i = m;
    } else {
      d += g[i];
    }
  }
  cout << d;
}
