#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
long long a[200011];
string s;
int main() {
  long long n, k, i, x, res = 0, j;
  cin >> n >> k;
  for (i = 0; i < n; i++) cin >> a[i];
  cin >> s;
  char C = 'A';
  for (i = 0; i < n; i++) {
    x = k;
    if (s[i] == C) v.push_back(a[i]);
    if (s[i] != C || i == n - 1) {
      if (i == n - 1 && s[i] != C) res += a[i];
      C = s[i];
      sort(v.begin(), v.end());
      if (v.size()) {
        for (j = v.size() - 1; j >= 0; j--) {
          if (x > 0) {
            res += v[j];
            x--;
          }
        }
        v.erase(v.begin(), v.end());
      }
      v.push_back(a[i]);
    }
  }
  cout << res;
  return 0;
}
