#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  long long n, k;
  cin >> n >> k;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
  }
  string s;
  cin >> s;
  long long sum = 0;
  multiset<long long> a;
  a.insert(v[0]);
  for (long long i = 1; i < s.size(); i++) {
    if (s[i] == s[i - 1]) {
      a.insert(v[i]);
    } else {
      if (a.size() > k) {
        long long t = a.size() - k;
        for (auto i : a) {
          if (t <= 0) {
            sum += i;
          }
          t--;
        }
      } else {
        for (auto i : a) {
          sum += i;
        }
      }
      a.clear();
      a.insert(v[i]);
    }
  }
  if (a.size() > k) {
    long long t = a.size() - k;
    for (auto i : a) {
      if (t <= 0) {
        sum += i;
      }
      t--;
    }
  } else {
    for (auto i : a) {
      sum += i;
    }
  }
  cout << sum;
  return 0;
}
