#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  long long k;
  cin >> k;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  string s;
  cin >> s;
  long long y = s.length();
  s[y] = '0';
  s = s + ' ';
  vector<vector<long long>> v(26);
  long long sum = 0;
  for (int i = 0; i < s.length() - 1; i++) {
    if (s[i] == s[i + 1]) {
      v[s[i] - 97].push_back(a[i]);
    }
    if (s[i] != s[i + 1]) {
      v[s[i] - 97].push_back(a[i]);
      if (k > v[s[i] - 97].size()) {
        for (int j = 0; j < v[s[i] - 97].size(); j++)
          sum = sum + v[s[i] - 97][j];
      } else {
        sort(v[s[i] - 97].begin(), v[s[i] - 97].end());
        for (int j = v[s[i] - 97].size() - 1; j >= v[s[i] - 97].size() - k;
             j--) {
          sum = sum + v[s[i] - 97][j];
        }
      }
      v[s[i] - 97].clear();
    }
  }
  cout << sum;
}
