#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int mod = 1e9 + 7, mod1 = 1e9 + 17, bas = 29;
const int nmax = 1e5 + 10;
int st[nmax][2], h[nmax][2];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  pair<int, int> a[n];
  for (int i = 0; i < n; i++) cin >> a[i].first, a[i].second = i;
  string s;
  cin >> s;
  sort(a, a + n);
  reverse(a, a + n);
  int r = 0, w = 0, o = 0, q = 0, t = 0;
  for (int i = 0; i < n; i++) {
    int t = -1;
    if (s[a[i].second] != 'R') {
      if (s[a[i].second] == 'W') w += a[i].first, t = 1;
      if (s[a[i].second] == 'O') o += a[i].first, t = 0;
      q++;
    }
    if (q == k) {
      if (o && w) break;
      q--;
      if (t == 1)
        w -= a[i].first;
      else
        o -= a[i].first;
    }
  }
  if (q == k && w && o)
    q = 1, w += o;
  else
    t++;
  o = 0, q = 0;
  for (int i = 0; i < n; i++) {
    int t = -1;
    if (s[a[i].second] != 'W') {
      if (s[a[i].second] == 'R') r += a[i].first, t = 1;
      if (s[a[i].second] == 'O') o += a[i].first, t = 0;
      q++;
    }
    if (q == k) {
      if (o && r) break;
      q--;
      if (t == 1)
        r -= a[i].first;
      else
        o -= a[i].first;
    }
  }
  if (q == k && r && o)
    q = 1, r += o;
  else
    t++;
  if (t == 2)
    cout << -1;
  else
    cout << max(r, w);
}
