void main()
{
    long[] nk = rdRow;
    long n = nk[0], k = nk[1];

    long[] rsp = rdRow;

    string t = rdStr;

    string u;
    long score;
    foreach (i, x; t)
    {
        dchar now = check(x);
        if (i >= k)
        {
            if (u[i-k] == now)
            {
                if (i + k >= n)
                {
                    u ~= check(now);
                }
                else
                {
                    u ~= check(check(t[i+k]));
                }
            }
            else
            {
                u ~= now;
                score += calc(now, rsp);
            }
        }
        else
        {
            u ~= now;
            score += calc(now, rsp);
        }
    }

    score.writeln;
}

dchar check(dchar x)
{
    if (x == 'r') return 'p';
    else if (x == 's') return 'r';
    else return 's';
}

long calc(dchar x, long[] arr)
{
    if (x == 'r') return arr[0];
    else if (x == 's') return arr[1];
    else return arr[2];
}

T rdElem(T = long)()
{
    //import std.stdio : readln;
    //import std.string : chomp;
    //import std.conv : to;

    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;

dchar[] rdDchar()
{
    //import std.conv : to;

    return rdStr.to!(dchar[]);
}

T[] rdRow(T = long)()
{
    //import std.stdio : readln;
    //import std.array : split;
    //import std.conv : to;

    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    //import std.range : iota;
    //import std.algorithm : map;
    //import std.array : array;

    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    //import std.stdio : write, writeln;

    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;