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

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "a", long, "b");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long n, k;
    scan(n, k);
    long r, s, p;
    scan(r, s, p);
    auto t = sread();
    long sum;
    auto check = new bool[](k);
    foreach (i; iota(k))
    {
        switch (t[i])
        {
        case 'r':
            sum += p;
            break;
        case 's':
            sum += r;
            break;
        case 'p':
            sum += s;
            break;
        default:
            assert(0);
        }
    }
    foreach (i; iota(k, n))
    {
        switch (t[i])
        {
        case 'r':
            if (t[i - k] != 'r' || check[i % k])
            {
                sum += p;
                check[i % k] = false;
            }
            else
            {
                check[i % k] = true;
            }
            break;
        case 's':
            if (t[i - k] != 's' || check[i % k])
            {
                sum += r;
                check[i % k] = false;
            }
            else
            {
                check[i % k] = true;
            }
            break;
        case 'p':
            if (t[i - k] != 'p' || check[i % k])
            {
                sum += s;
                check[i % k] = false;
            }
            else
            {
                check[i % k] = true;
            }
            break;
        default:
            assert(0);
        }
    }
    sum.writeln();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}
