#include <bits/stdc++.h>
using namespace std;
int n, k, cnt;
long long int ans;
int main() {
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  string s;
  cin >> s;
  int l = 0, r = 0;
  for (int i = 1; i < n; i++) {
    if (s[i] == s[i - 1]) {
      r = i;
    } else {
      r = i;
      sort(a.begin() + l, a.begin() + r);
      for (int j = r - 1; j >= max(r - k, l); j--) ans += a[j];
      l = i;
    }
  }
  sort(a.begin() + l, a.begin() + n);
  for (int j = n - 1; j >= max(n - k, l); j--) ans += a[j];
  cout << ans;
  return 0;
}
