#include <bits/stdc++.h>
int b[200010];
int b1[200010];
int b2[200010];
int b3[200010];
using namespace std;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
  }
  char* c;
  c = (char*)malloc(n + 1);
  scanf("%s", c);
  int n1 = 0, n2 = 0, n3 = 0;
  for (int i = 0; i < n; i++) {
    if (c[i] == 'W') {
      b1[n1++] = b[i];
    }
    if (c[i] == 'R') {
      b2[n2++] = b[i];
    }
    if (c[i] == 'O') {
      b3[n3++] = b[i];
    }
  }
  sort(b1, b1 + n1);
  sort(b2, b2 + n2);
  sort(b3, b3 + n3);
  reverse(b1, b1 + n1);
  reverse(b2, b2 + n2);
  reverse(b3, b3 + n3);
  for (int i = 1; i < n1; i++) {
    b1[i] += b1[i - 1];
  }
  for (int i = 1; i < n2; i++) {
    b2[i] += b2[i - 1];
  }
  for (int i = 1; i < n3; i++) {
    b3[i] += b3[i - 1];
  }
  int maxc = -1;
  for (int i = 1; i <= min(n3, k - 1); i++) {
    if (k - i <= n1) {
      maxc = max(maxc, b3[i - 1] + b1[k - i - 1]);
    }
    if (k - i <= n2) {
      maxc = max(maxc, b3[i - 1] + b2[k - i - 1]);
    }
  }
  printf("%d\n", maxc);
  free(c);
  return 0;
}
