#include <bits/stdc++.h>
using namespace std;
vector<long long> v, use;
signed main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long n, k, x;
  cin >> n >> k;
  for (long long i = 0; i < n; ++i) cin >> x, v.push_back(x);
  string str;
  cin >> str;
  long long tot = 0, ans = 0;
  for (long long i = 0; i < (long long)(str).size() - 1; ++i) {
    use.push_back(v[i]), ++tot;
    if (str[i] != str[i + 1]) {
      sort((use).begin(), (use).end());
      reverse((use).begin(), (use).end());
      for (long long j = 0; j < k && j < tot; ++j) ans += use[j];
      use.clear();
      tot = 0;
    }
  }
  if (tot == 0) {
    ans += v.back();
  } else {
    ++tot;
    use.push_back(v.back());
    sort((use).begin(), (use).end());
    reverse((use).begin(), (use).end());
    for (long long j = 0; j < k && j < tot; ++j) ans += use[j];
    use.clear();
    tot = 0;
  }
  cout << ans << '\n';
}
