#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int exp(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int main() {
  cin.sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  long long int a[n];
  vector<long long int> v;
  vector<long long int> ans;
  for (long long i = 0, _n = (n); i < _n; i++) cin >> a[i];
  string s;
  cin >> s;
  int cnt = 0;
  long long int sum2 = 0;
  for (long long i = 0, _n = (n - 1); i < _n; i++) {
    sum2 += a[i];
    if (s[i] == s[i + 1]) {
      cnt++;
      v.push_back(a[i]);
    } else {
      if (cnt >= k) {
        v.push_back(a[i]);
        long long int sum = 0;
        sort(v.begin(), v.end());
        for (int j = v.size() - 1; j >= v.size() - k; j--) {
          sum += v[j];
        }
        ans.push_back(sum);
        cnt = 0;
        v.clear();
        sum2 = 0;
      } else {
        ans.push_back(sum2);
        sum2 = 0;
        v.clear();
        cnt = 0;
      }
    }
  }
  if (v.size() > 0) {
    if (cnt >= k) {
      v.push_back(a[n - 1]);
      long long int anshi = 0;
      sort(v.begin(), v.end());
      for (int j = v.size() - 1; j >= v.size() - k; j--) {
        anshi += v[j];
      }
      ans.push_back(anshi);
    } else {
      v.push_back(a[n - 1]);
      long long int anshilub = 0;
      for (long long j = 0, _n = (v.size()); j < _n; j++) anshilub += v[j];
      ans.push_back(anshilub);
    }
  } else
    ans.push_back(a[n - 1]);
  long long int answer = 0;
  for (long long i = 0, _n = (ans.size()); i < _n; i++) {
    answer += ans[i];
  }
  cout << answer;
  return 0;
}
