#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long a[200003], cs[200003], md[200003];
int main() {
  long long n, k, i, j;
  cin >> n >> k;
  string s;
  for (i = 0; i < n; i++)
    cin >> a[i], cs[i] = (i == 0 ? a[i] : a[i] + cs[i - 1]);
  cin >> s;
  long long mx = 0, ans = 0;
  i = 0;
  while (i < n) {
    mx = 0;
    j = i;
    while (j < n && s[i] == s[j]) j++;
    j--;
    if (j - i + 1 >= k) {
      sort(a + i, a + j + 1);
      for (int o = j; o > j - k; o--) ans += a[o];
    } else
      ans += cs[j] - cs[i] + a[i];
    i = j + 1;
  }
  cout << ans;
}
