#include <bits/stdc++.h>
using namespace std;
const long long int OO = 2e7;
const double EPS = (1e-7);
bool sort_p(pair<int, int> a, pair<int, bool> b) { return a.second < b.second; }
long long int mod = 998244353;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  int k, n;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < (int)(n); ++i) cin >> a[i];
  string s;
  cin >> s;
  long long int ans = 0;
  vector<int> q;
  for (int i = 0; i < (int)(n); ++i) {
    if (i == n - 1) {
      q.push_back(a[i]);
      sort(((q).begin()), ((q).end()), greater<int>());
      int x = 1;
      for (int j = 0; j < ((int)((q).size())); ++j) {
        if (x > k) break;
        ans = ans + q[j];
        x++;
      }
      q = vector<int>(0);
      continue;
    }
    if (s[i] == s[i + 1]) {
      q.push_back(a[i]);
    } else if (s[i] != s[i + 1]) {
      q.push_back(a[i]);
      sort(((q).begin()), ((q).end()), greater<int>());
      int x = 1;
      for (int j = 0; j < ((int)((q).size())); ++j) {
        if (x > k) break;
        ans = ans + q[j];
        x++;
      }
      q = vector<int>(0);
    }
  }
  cout << ans;
}
