#include <bits/stdc++.h>
using namespace std;
class CBrutality {
 public:
  void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long n, k;
    in >> n >> k;
    vector<long long> a(n);
    for (long long& i : a) {
      in >> i;
    }
    string s;
    in >> s;
    long long ans = 0;
    for (int i = 0; i < s.size(); ++i) {
      multiset<long long, greater<long long>> a1;
      int j = i;
      while (j < n && s[i] == s[j]) {
        a1.insert(a[j]);
        ++j;
      }
      long long c = 0;
      for (long long j1 : a1) {
        if (c >= k) break;
        ans += j1;
        ++c;
      }
      i = j - 1;
    }
    out << ans << "\n";
  }
};
int main() {
  CBrutality solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
