#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  string s;
  cin >> s;
  if (k == 1) {
    cout << -1;
    return 0;
  }
  unordered_map<char, vector<int>> ad;
  for (int i = 0; i < n; i++) ad[s[i]].push_back(a[i]);
  int ans = -1;
  for (auto it : ad) sort(ad[it.first].begin(), ad[it.first].end());
  auto ag = ad;
  vector<int> af;
  if (!ad['O'].empty() && !ad['R'].empty()) {
    af.push_back(ad['O'].back());
    ad['O'].pop_back();
    af.push_back(ad['R'].back());
    ad['R'].pop_back();
    while (af.size() < k) {
      if (!ad['O'].empty() && !ad['R'].empty()) {
        if (ad['O'].back() > ad['R'].back()) {
          af.push_back(ad['O'].back());
          ad['O'].pop_back();
        } else {
          af.push_back(ad['R'].back());
          ad['R'].pop_back();
        }
      } else if (!ad['O'].empty()) {
        af.push_back(ad['O'].back());
        ad['O'].pop_back();
      } else if (!ad['R'].empty()) {
        af.push_back(ad['R'].back());
        ad['R'].pop_back();
      } else
        break;
    }
    if (af.size() >= k) {
      int as = 0;
      for (auto it : af) as += it;
      ans = max(ans, as);
    }
  }
  af.clear();
  if (!ag['O'].empty() && !ag['W'].empty()) {
    af.push_back(ag['O'].back());
    ag['O'].pop_back();
    af.push_back(ag['W'].back());
    ag['W'].pop_back();
    while (af.size() < k) {
      if (!ag['O'].empty() && !ag['W'].empty()) {
        if (ag['O'].back() > ag['W'].back()) {
          af.push_back(ag['O'].back());
          ag['O'].pop_back();
        } else {
          af.push_back(ag['W'].back());
          ag['W'].pop_back();
        }
      } else if (!ag['O'].empty()) {
        af.push_back(ag['O'].back());
        ag['O'].pop_back();
      } else if (!ag['W'].empty()) {
        af.push_back(ag['W'].back());
        ag['W'].pop_back();
      } else
        break;
    }
    if (af.size() >= k) {
      int as = 0;
      for (auto it : af) as += it;
      ans = max(ans, as);
    }
  }
  cout << ans;
}
