#include <bits/stdc++.h>
using namespace std;
long long n, k, a[200005], W[200005], O[200005], R[2000005], ans;
long long r = 0;
long long w = 0;
long long o = 0;
string s;
bool kt(long long a, long long b) { return (a > b); }
int32_t main() {
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  cin >> s;
  for (long long i = 0; i < s.size(); i++) {
    if (s[i] == 'R') {
      r++;
      R[r] = a[i + 1];
    } else if (s[i] == 'O') {
      o++;
      O[o] = a[i + 1];
    } else {
      w++;
      W[w] = a[i + 1];
    }
  }
  sort(R + 1, R + 1 + r, kt);
  sort(O + 1, O + 1 + o, kt);
  sort(W + 1, W + 1 + w, kt);
  for (long long i = 1; i <= r; i++) {
    R[i] = R[i - 1] + R[i];
  }
  for (long long i = 1; i <= o; i++) {
    O[i] = O[i - 1] + O[i];
  }
  for (long long i = 1; i <= w; i++) {
    W[i] = W[i - 1] + W[i];
  }
  if (r + o < k && w + o < k)
    cout << -1;
  else if (o == 0)
    cout << -1;
  else {
    ans = -1;
    for (long long i = 1; i < k; i++) {
      long long tam = k - i;
      if (tam <= w || tam <= r) {
        if (tam > w) {
          ans = max(ans, R[tam] + O[i]);
        } else if (tam > r) {
          ans = max(ans, W[tam] + O[i]);
        } else
          ans = max(ans, max(W[tam] + O[i], R[tam] + O[i]));
      }
    }
    cout << ans;
  }
}
