#include <bits/stdc++.h>
using namespace std;
long long getTop(long long prefix[], long long n, long long size) {
  if (n == 0 || size == 0) return 0;
  return prefix[n - 1];
}
const long long maxn = 200005;
long long redPrefix[maxn], orangePrefix[maxn], whitePrefix[maxn];
vector<long long> red, orange, white;
long long arr[maxn];
char firstchar;
int main() {
  long long n, k;
  cin >> n >> k;
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (long long i = 0; i < n; i++) {
    char c;
    cin >> c;
    if (i == 0) firstchar = c;
    switch (c) {
      case 'R':
        red.push_back(arr[i]);
        break;
      case 'O':
        orange.push_back(arr[i]);
        break;
      case 'W':
        white.push_back(arr[i]);
        break;
    }
  }
  if (orange.size() == 0) {
    cout << "-1\n";
    return 0;
  }
  sort(red.begin(), red.end(), greater<long long>());
  sort(orange.begin(), orange.end(), greater<long long>());
  sort(white.begin(), white.end(), greater<long long>());
  for (long long i = 0; i < red.size(); i++) {
    if (i == 0)
      redPrefix[i] = red[i];
    else
      redPrefix[i] = red[i] + redPrefix[i - 1];
  }
  for (long long i = 0; i < orange.size(); i++) {
    if (i == 0)
      orangePrefix[i] = orange[i];
    else
      orangePrefix[i] = orange[i] + orangePrefix[i - 1];
  }
  for (long long i = 0; i < white.size(); i++) {
    if (i == 0)
      whitePrefix[i] = white[i];
    else
      whitePrefix[i] = white[i] + whitePrefix[i - 1];
  }
  long long ans = -1;
  long long kk = 1;
  for (; kk < k; kk++) {
    if (kk <= orange.size() && k - kk <= red.size()) {
      long long ttr = getTop(orangePrefix, kk, orange.size()) +
                      getTop(redPrefix, k - kk, red.size());
      ans = max(ans, ttr);
    }
  }
  kk = 1;
  for (; kk < k; kk++) {
    if (kk <= orange.size() && k - kk <= white.size()) {
      long long ttr = getTop(orangePrefix, kk, orange.size()) +
                      getTop(whitePrefix, k - kk, white.size());
      ans = max(ans, ttr);
    }
  }
  cout << ans << '\n';
}
