#include <bits/stdc++.h>
const int N = 100100;
const long long mod = 1e9 + 7;
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  string s;
  cin >> s;
  vector<pair<long long, long long>> v[26];
  long long cnt = 1, st = 0;
  s += '?';
  for (long long i = 1; i <= n; i++) {
    if (s[i] == s[i - 1]) {
      cnt++;
    } else {
      v[s[i - 1] - 'a'].push_back({st, i - 1});
      st = i;
      cnt = 1;
    }
  }
  long long ans = 0;
  for (long long i = 0; i < 26; i++) {
    for (long long j = 0; j < v[i].size(); j++) {
      st = v[i][j].first;
      long long en = v[i][j].second;
      if (en - st + 1 <= k)
        for (long long x = st; x <= en; x++) ans += a[x];
      if (en - st + 1 > k) {
        vector<long long> tmp;
        for (long long x = st; x <= en; x++) {
          tmp.push_back(a[x]);
        }
        sort(tmp.rbegin(), tmp.rend());
        for (long long x = 0; x < k; x++) {
          ans += tmp[x];
        }
      }
    }
  }
  cout << ans << "\n";
}
