#include <bits/stdc++.h>
using namespace std;
vector<int> r, o, w;
int n, k, b[200001], ans = -1;
char s[200001];
bool cmp(int x, int y) { return x > y; }
int rua(vector<int> x, vector<int> y) {
  int _1 = 1, _2 = 1, res = x[0] + y[0];
  for (int i = 3; i <= k; i++) {
    if (_1 >= x.size()) {
      res += y[_2++];
      continue;
    }
    if (_2 >= y.size()) {
      res += x[_1++];
      continue;
    }
    res += (x[_1] > y[_2]) ? x[_1++] : y[_2++];
  }
  return res;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'R') r.push_back(b[i]);
    if (s[i] == 'O') o.push_back(b[i]);
    if (s[i] == 'W') w.push_back(b[i]);
  }
  sort(r.begin(), r.end(), cmp);
  sort(o.begin(), o.end(), cmp);
  sort(w.begin(), w.end(), cmp);
  if (!o.size() || k < 2) return printf("-1\n"), 0;
  if (r.size() && r.size() + o.size() >= k) ans = max(ans, rua(r, o));
  if (w.size() && o.size() + w.size() >= k) ans = max(ans, rua(o, w));
  printf("%d\n", ans);
  return 0;
}
