#include <bits/stdc++.h>
using namespace std;
long n, k, i, l, j;
long long a = 0;
string s;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> k;
  vector<long long> v(n);
  for (i = 0; i < n; ++i) cin >> v[i];
  cin >> s;
  j = 0;
  for (i = j; i < n; i = j) {
    while (s[i] == s[j]) ++j;
    sort(v.begin() + i, v.begin() + j, greater<long long>());
    for (l = i; l < min(k + i, j); ++l) a += v[l];
  }
  cout << a << "\n";
  return 0;
}
