import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.format;

void main() {
  int n, k;
  int r, s, p;
  auto z = readln;
  formattedRead (z, " %d %d", &n, &k);
  z = readln;
  formattedRead (z, " %d %d %d", &r, &s, &p);
  long res;
  z = readln;
  void upd (char c) {
    if (c == 'r') res += p;
    if (c == 'p') res += s;
    if (c == 's') res += r;
  }
  foreach (i; 0 .. k) {
    char[] x;
    for (int j = i; j < n; j += k) x ~= z[j];
    debug stderr.writeln (x);
    char last = 0;
    foreach (o; 0 .. x.length) {
      if (last != x[o]) {
        upd (x[o]);
        last = x[o];
      } else {
        last = 0;
      }
    }
    debug stderr.writeln (res);
  }
  writeln (res);
}

