#include <bits/stdc++.h>
using namespace std;
long long point[200005];
priority_queue<long long> pq;
int main() {
  int n, mx;
  cin >> n >> mx;
  for (int i = 0; i < n; ++i) {
    cin >> point[i];
  }
  string s;
  cin >> s;
  s += '.';
  char c = '.';
  int i, k, t, xd = 0;
  vector<long long> v;
  long long ans = 0;
  for (i = 0; i <= n; i++) {
    if (s[i] != c) {
      k = 0;
      c = s[i];
      while (!pq.empty()) {
        if (k < mx) {
          k++;
          ans += pq.top();
        }
        pq.pop();
      }
    }
    pq.push(point[i]);
  }
  cout << ans << endl;
}
