#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
int n, k;
vector<int> mas;
string c;
vector<int> ms[3];
vector<long long> pref[3];
int hsh(char a) {
  if (a == 'W') return 0;
  if (a == 'O') return 1;
  if (a == 'R') return 2;
  return 4;
}
void calc(int v) {
  pref[v].resize(ms[v].size());
  for (int i = 0; i < ms[v].size(); i++) {
    pref[v][i] = (i == 0 ? 0 : pref[v][i - 1]) + ms[v][i];
  }
}
long long getS(int v, int kek) {
  if (ms[v].size() < kek) return -inf;
  if (kek == 0) return -inf;
  return pref[v][kek - 1];
}
int main() {
  cin >> n >> k;
  mas.resize(n);
  for (auto &x : mas) cin >> x;
  for (int i = 0; i < n; i++) {
    char a;
    cin >> a;
    ms[hsh(a)].push_back(mas[i]);
  }
  for (int i = 0; i < 3; i++) {
    sort(ms[i].begin(), ms[i].end());
    reverse(ms[i].begin(), ms[i].end());
  }
  for (int i = 0; i < 3; i++) calc(i);
  long long ans = -1;
  for (int i = 0; i < ms[1].size(); i++) {
    ans = max(ans, pref[1][i] + max(getS(0, k - i - 1), getS(2, k - i - 1)));
  }
  cout << ans;
  return 0;
}
