#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 5;
const int INF = (1 << 31) - 1;
vector<int> values[3];
string s;
int b[MAX];
int n, k;
int roll(int id) {
  int total = values[id].back() + values[2].back();
  int ptr_i = (int)values[id].size() - 2;
  int ptr_2 = (int)values[2].size() - 2;
  int left = k - 2;
  while (left) {
    if (ptr_i < 0) {
      total += values[2][ptr_2--];
    } else if (ptr_2 < 0) {
      total += values[id][ptr_i--];
    } else if (values[id][ptr_i] >= values[2][ptr_2]) {
      total += values[id][ptr_i--];
    } else {
      total += values[2][ptr_2--];
    }
    left--;
  }
  return total;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (int i = int(0); i < int(n); i++) {
    cin >> b[i];
  }
  cin >> s;
  int oranges = 0;
  for (int i = int(0); i < int(s.size()); i++) {
    char each = s[i];
    oranges += each == 'O';
    int id = each == 'R' ? 0 : (each == 'W' ? 1 : 2);
    values[id].push_back(b[i]);
  }
  if (k == 1 || oranges % n == 0) {
    puts("-1");
    return 0;
  }
  for (int i = int(0); i < int(3); i++) {
    sort(values[i].begin(), values[i].end());
  }
  int best = -INF;
  for (int i = int(0); i < int(2); i++) {
    if (!values[i].empty() &&
        (int)values[i].size() + (int)values[2].size() >= k) {
      best = max(best, roll(i));
    }
  }
  cout << (best == -INF ? -1 : best) << '\n';
  return 0;
}
