#include <bits/stdc++.h>
using namespace std;
struct output {};
struct input {};
template <typename T>
output operator,(output l, const T& r) {
  cout << r;
  return l;
}
template <typename T>
input operator,(input l, T& r) {
  cin >> r;
  return l;
}
input I;
output P;
char sp = ' ', nl = '\n';
string spp = ", ", sdp = " | ";
const long long SZ = 2e5 + 10;
long long suka(vector<long long>& a, vector<long long>& b, long long k) {
  long long i = 1, j = 1, res = a[0] + b[0];
  for (long long _ = (2); _ < (k); _++) {
    if (i >= a.size()) {
      res += b[j++];
      continue;
    }
    if (j >= b.size()) {
      res += a[i++];
      continue;
    }
    res += (a[i] > b[j]) ? a[i++] : b[j++];
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, k;
  I, n, k;
  long long a[SZ];
  for (long long i = (0); i < (n); i++) I, a[i];
  string s;
  I, s;
  vector<long long> red, orange, white;
  for (long long i = (0); i < (n); i++) {
    if (s[i] == 'W') white.push_back(a[i]);
    if (s[i] == 'O') orange.push_back(a[i]);
    if (s[i] == 'R') red.push_back(a[i]);
  }
  auto cmp = [](long long a, long long b) { return a > b; };
  sort(white.begin(), white.end(), cmp);
  sort(orange.begin(), orange.end(), cmp);
  sort(red.begin(), red.end(), cmp);
  long long ans = -1;
  if (!orange.size() || k < 2) {
    P, -1, nl;
    return 0;
  }
  if (red.size() && red.size() + orange.size() >= k)
    ans = max(ans, suka(red, orange, k));
  if (white.size() && orange.size() + white.size() >= k)
    ans = max(ans, suka(orange, white, k));
  P, ans, nl;
}
