#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const long long maxn = (long long)1e6 + 6;
const long double EPS = 1e-9;
const long long INF = (long long)1e18 + 18;
const long long mod = (long long)1e9 + 7;
long long n, K, a[maxn], ans = 0;
;
string in;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> K;
  for (long long i = 0; i < n; i++) cin >> a[i];
  cin >> in;
  for (long long i = 0; i < n; i++) {
    long long j = i;
    vector<long long> tmp;
    while (j < n && in[i] == in[j]) {
      tmp.push_back(a[j]);
      j++;
    }
    long long len = j - i;
    if (len > K) {
      sort(tmp.begin(), tmp.end());
      for (long long k = tmp.size() - 1; k >= tmp.size() - K; k--) {
        ans += tmp[k];
      }
    } else {
      ans += accumulate(tmp.begin(), tmp.end(), 0LL);
    }
    i = j - 1;
  }
  cout << ans << '\n';
  return 0;
}
