#include <bits/stdc++.h>
using namespace std;
const int N = (int)3e5;
int main(void) {
  int n, k;
  char buf;
  long long a[N];
  vector<long long> red, white, orange;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%I64d", a + i);
  scanf("%c", &buf);
  for (int i = 0; i < n; i++) {
    scanf("%c", &buf);
    if (buf == 'R')
      red.push_back(a[i]);
    else if (buf == 'W')
      white.push_back(a[i]);
    else
      orange.push_back(a[i]);
  }
  sort(orange.begin(), orange.end());
  sort(white.begin(), white.end());
  sort(red.begin(), red.end());
  long long ans = -1LL;
  if (orange.size() == 0) {
    printf("-1");
    return 0;
  }
  if (red.size() > 0) {
    int ptr1 = orange.size() - 1;
    int ptr2 = red.size() - 1;
    int left = k - 2;
    long long curans = orange[ptr1] + red[ptr2];
    ptr1--;
    ptr2--;
    while (left > 0 && (ptr1 >= 0 || ptr2 >= 0)) {
      if (ptr1 < 0 || (min(ptr1, ptr2) >= 0 && orange[ptr1] < red[ptr2])) {
        curans += red[ptr2--];
        left--;
      } else if (ptr2 < 0 ||
                 (min(ptr1, ptr2) >= 0 && orange[ptr1] >= red[ptr2])) {
        curans += orange[ptr1--];
        left--;
      }
    }
    if (left == 0) ans = curans;
  }
  if (white.size() > 0) {
    int ptr1 = orange.size() - 1;
    int ptr2 = white.size() - 1;
    int left = k - 2;
    long long curans = orange[ptr1] + white[ptr2];
    ptr1--;
    ptr2--;
    while (left > 0 && (ptr1 >= 0 || ptr2 >= 0)) {
      if (ptr1 < 0 || (min(ptr1, ptr2) >= 0 && orange[ptr1] < white[ptr2])) {
        curans += white[ptr2--];
        left--;
      } else if (ptr2 < 0 ||
                 (min(ptr1, ptr2) >= 0 && orange[ptr1] >= white[ptr2])) {
        curans += orange[ptr1--];
        left--;
      }
    }
    if (left == 0) ans = max(ans, curans);
  }
  printf("%I64d", ans);
  return 0;
}
