#include <bits/stdc++.h>
const long long LINF = 1e18;
const int INF = 1e9;
const int M = 1e9 + 7;
const double EPS = 1e-9;
using namespace std;
int c[200200];
vector<int> orange;
vector<int> red;
vector<int> white;
string s;
int n, k;
long long ansR() {
  if (!red.size() || !orange.size() || (orange.size() + red.size()) < k)
    return -1;
  int uk1 = 1;
  int uk2 = 1;
  long long ans = red[0] + orange[0];
  while (uk1 < red.size() && uk2 < orange.size() && uk1 + uk2 < k) {
    if (red[uk1] < orange[uk2])
      ans += orange[uk2++];
    else
      ans += red[uk1++];
  }
  while (uk1 < red.size() && uk1 + uk2 < k) ans += red[uk1++];
  while (uk2 < orange.size() && uk1 + uk2 < k) ans += orange[uk2++];
  return ans;
}
long long ansW() {
  if (!white.size() || !orange.size() || (white.size() + orange.size()) < k)
    return -1;
  int uk1 = 1;
  int uk2 = 1;
  long long ans = white[0] + orange[0];
  while (uk1 < white.size() && uk2 < orange.size() && uk1 + uk2 < k) {
    if (white[uk1] < orange[uk2])
      ans += orange[uk2++];
    else
      ans += white[uk1++];
  }
  while (uk1 < white.size() && uk1 + uk2 < k) ans += white[uk1++];
  while (uk2 < orange.size() && uk1 + uk2 < k) ans += orange[uk2++];
  return ans;
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> c[i];
  cin >> s;
  if (k == 1) {
    cout << "-1";
    return 0;
  }
  for (int i = 0; i < n; i++)
    if (s[i] == 'O')
      orange.push_back(c[i]);
    else if (s[i] == 'R')
      red.push_back(c[i]);
    else
      white.push_back(c[i]);
  sort(red.begin(), red.end(), greater<int>());
  sort(white.begin(), white.end(), greater<int>());
  sort(orange.begin(), orange.end(), greater<int>());
  cout << max(ansR(), ansW());
}
