#include <iostream>
#include <string>
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  int r, s, p;
  cin >> r >> s >> p;
  string t;
  cin >> t;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i >= k && t[i] == t[i-k]) {
      t[i] = ' ';
      continue;
    }
    if (t[i] == 'r') ans += p;
    if (t[i] == 's') ans += r;
    if (t[i] == 'p') ans += s;
  }
  cout << ans << endl;
}