#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int n, k, sum = 0;
  cin >> n >> k;
  long long int a[n];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  string s;
  cin >> s;
  vector<long long int> v;
  v.push_back(a[0]);
  for (long long int i = 1; s[i]; i++) {
    if (s[i] == s[i - 1])
      v.push_back(a[i]);
    else {
      sort(v.rbegin(), v.rend());
      for (long long int i = 0; i < k && i < v.size(); i++) {
        sum += v[i];
      }
      v.clear();
      v.push_back(a[i]);
    }
  }
  sort(v.rbegin(), v.rend());
  for (long long int i = 0; i < k && i < v.size(); i++) sum += v[i];
  cout << sum;
}
