import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

immutable long MOD = 998244353;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto K = s[1];
    s = readln.split.map!(to!int);
    auto R = s[0];
    auto S = s[1];
    auto P = s[2];
    auto T = readln.chomp;

    int[dchar] score;
    score['r'] = P;
    score['s'] = R;
    score['p'] = S;
    auto past = new dchar[](N);
    int ans = 0;

    foreach (i; 0..N) {
        if (i < K) {
            ans += score[T[i]];
            past[i] = T[i];
        } else if (past[i-K] != T[i]) {
            ans += score[T[i]];
            past[i] = T[i];
        } else {
            past[i] = '.';
        }
    }

    ans.writeln;
}