#include <bits/stdc++.h>
using namespace std;
int s[200010];
pair<int, int> q1[200010], q2[200010];
int num1 = 0, num2 = 0;
char st[200010];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; ++i) scanf("%d", &s[i]);
  scanf("%s", st + 1);
  for (int i = 1; i <= n; ++i)
    if (st[i] == 'R')
      q1[++num1] = make_pair(-s[i], 0);
    else if (st[i] == 'O')
      q1[++num1] = make_pair(-s[i], 1), q2[++num2] = make_pair(-s[i], 1);
    else
      q2[++num2] = make_pair(-s[i], 0);
  sort(q1 + 1, q1 + num1 + 1);
  sort(q2 + 1, q2 + num2 + 1);
  long long ans = -10000;
  if (k == 1) {
    puts("-1");
    return 0;
  }
  if (k <= num1) {
    bool flag = 0;
    long long res = 0;
    for (int i = 1; i <= k; ++i) {
      res += -q1[i].first;
      if (i > 1 && q1[i].second != q1[i - 1].second) flag = 1;
    }
    if (flag)
      ans = res;
    else {
      res += q1[k].first;
      int op = q1[k].second;
      for (int i = k + 1; i <= num1; ++i)
        if (q1[i].second != op) {
          res -= q1[i].first, flag = 1;
          break;
        }
      if (flag) ans = res;
    }
  }
  if (k <= num2) {
    bool flag = 0;
    long long res = 0;
    for (int i = 1; i <= k; ++i) {
      res += -q2[i].first;
      if (i > 1 && q2[i].second != q2[i - 1].second) flag = 1;
    }
    if (flag)
      ans = max(ans, res);
    else {
      res += q2[k].first;
      int op = q2[k].second;
      for (int i = k + 1; i <= num2; ++i)
        if (q2[i].second != op) {
          res -= q2[i].first, flag = 1;
          break;
        }
      if (flag) ans = max(ans, res);
    }
  }
  if (ans < 0) {
    puts("-1");
  } else
    printf("%lld", ans);
  return 0;
}
