#include <bits/stdc++.h>
using namespace std;
int n, k;
long long arr[200001];
vector<long long> v;
string s;
int find(int i) {
  int curr = v[i];
  int num = i;
  for (int j = i + 1; j < n; j++)
    if (v[j] == curr)
      num = j;
    else
      break;
  return num;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> arr[i];
  cin >> s;
  for (int i = 0; i < n; i++) {
    int a = s[i] - 'a';
    v.push_back(a);
  }
  int count = 1;
  long long d = 0;
  int prev;
  for (int i = 0; i < n; i++) {
    int nx = find(i);
    int dis = nx - i + 1;
    if (dis <= k) {
      for (int j = i; j <= nx; j++) d += arr[j];
    } else {
      sort(arr + i, arr + nx + 1);
      for (int j = nx; j >= nx - k + 1; j--) d += arr[j];
    }
    i = nx;
  }
  cout << d;
}
