import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, K;
    scan(N, K);
    long R, S, P;
    scan(R, S, P);
    auto T = sread();

    auto dp = new long[][](3, N);

    long pts(long x, long y)
    {
        if (x == 0)
            return T[y] == 's' ? R : 0;
        if (x == 1)
            return T[y] == 'p' ? S : 0;
        if (x == 2)
            return T[y] == 'r' ? P : 0;
        return long.min;
    }

    foreach (i; 0 .. N)
    {
        if (i < K)
        {
            dp[0][i] = pts(0, i);
            dp[1][i] = pts(1, i);
            dp[2][i] = pts(2, i);
        }
        else
        {
            dp[0][i] = max(dp[1][i - K], dp[2][i - K]) + pts(0, i);
            dp[1][i] = max(dp[0][i - K], dp[2][i - K]) + pts(1, i);
            dp[2][i] = max(dp[0][i - K], dp[1][i - K]) + pts(2, i);
        }
    }
    long ans;
    foreach (i; N - K .. N)
    {
        ans += max(dp[0][i], dp[1][i], dp[2][i]);
    }
    writeln(ans);
}
