#include <bits/stdc++.h>
using namespace std;
template <typename Arg1, typename Arg2>
ostream& operator<<(ostream& out, const pair<Arg1, Arg2>& x) {
  return out << "(" << x.first << "," << x.second << ")";
}
template <typename Arg1>
ostream& operator<<(ostream& out, const vector<Arg1>& a) {
  out << "[";
  for (const auto& x : a) out << x << ",";
  return out << "]";
}
template <typename Arg1>
ostream& operator<<(ostream& out, const set<Arg1>& a) {
  out << "[";
  for (const auto& x : a) out << x << ",";
  return out << "]";
}
template <typename Arg1, typename Arg2>
ostream& operator<<(ostream& out, const map<Arg1, Arg2>& a) {
  out << "[";
  for (const auto& x : a) out << x << ",";
  return out << "]";
}
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << " ] " << endl;
}
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args) {
  const string name = names.substr(0, names.find(','));
  cerr << name << " : " << arg1 << " | ";
  __trace__(names.substr(1 + (int)name.size()), args...);
}
clock_t time_p = clock();
void time_taken() {
  time_p = clock() - time_p;
  cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}
const long long mod = 1e9 + 7;
const long long INF = 1e18;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout.precision(12);
  cout << fixed;
  int n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  string s;
  cin >> s;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    map<long long, long long> m;
    int j = 0;
    for (j = i; j < n and s[j] == s[i]; j++) {
      m[a[j]]++;
    }
    i = j - 1;
    int cnt = 0;
    while ((int)m.size() and cnt < k) {
      long long add = min((long long)k - cnt, m.rbegin()->second);
      ans += add * m.rbegin()->first;
      m.erase(m.rbegin()->first);
      cnt += add;
    }
  }
  cout << ans << '\n';
  time_taken();
  return 0;
}
