#include <bits/stdc++.h>
using namespace std;
const int N = (int)(2e5 + 5);
int n, k;
int a[N];
string second;
vector<int> R, O, W;
int solve(const vector<int> &a, const vector<int> &b) {
  int sum = -1;
  if (a.size() > 0 && b.size() > 0 && a.size() + b.size() >= k) {
    sum = a[0] + b[0];
    int i = 1;
    int j = 1;
    while (i + j < k) {
      if (i < a.size()) {
        if (j < b.size()) {
          if (a[i] > b[j])
            sum += a[i++];
          else
            sum += b[j++];
        } else {
          sum += a[i++];
        }
      } else {
        sum += b[j++];
      }
    }
  }
  return sum;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  cin >> second;
  for (int i = 0; i < n; i++) switch (second[i]) {
      case 'W':
        W.push_back(a[i]);
        break;
      case 'R':
        R.push_back(a[i]);
        break;
      case 'O':
        O.push_back(a[i]);
        break;
    }
  if (k == 1 || O.empty() || (R.empty() && W.empty())) {
    cout << -1 << endl;
    return 0;
  }
  if (O.size() + R.size() < k && O.size() + W.size() < k) {
    cout << -1 << endl;
    return 0;
  }
  sort(R.begin(), R.end(), greater<int>());
  sort(W.begin(), W.end(), greater<int>());
  sort(O.begin(), O.end(), greater<int>());
  int sumR = solve(O, R);
  int sumW = solve(O, W);
  cout << max(sumR, sumW) << endl;
  return 0;
}
