#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, num, cnt, ans = 0;
  char ch;
  vector<long long> v, cons;
  map<long long, long long> mp;
  cin >> n >> k;
  string s;
  for (long long i = 0; i < n; i++) {
    cin >> num;
    v.push_back(num);
  }
  cin >> s;
  ch = s[0];
  cnt = 0;
  for (long long i = 0; i < n; i++) {
    if (s[i] == ch) {
      cons.push_back(v[i]);
      cnt++;
    } else {
      sort(cons.rbegin(), cons.rend());
      num = cons.size();
      for (long long j = 0; j < min(num, k); j++) ans += cons[j];
      cons.clear();
      cons.push_back(v[i]);
      ch = s[i];
    }
  }
  sort(cons.rbegin(), cons.rend());
  num = cons.size();
  for (long long j = 0; j < min(num, k); j++) ans += cons[j];
  cout << ans;
}
