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, "l    ", long, "r");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long n, k;
    scan(n, k);
    auto point = aryread(); // r, s, p
    auto t = readln().chomp().map!(x => "rsp".countUntil(x)).array();

    auto dp = new long[][](3, n);
    foreach (i; iota(n))
    {
        foreach (j; iota(3))
        {
            dp[j][i] = (j == (t[i] + 2) % 3) ? point[j] : 0;
            if (i >= k)
                dp[j][i] += max(dp[(j + 1) % 3][i - k], dp[(j + 2) % 3][i - k]);
        }
    }
    long ans;
    foreach (i; iota(k))
    {
        ans += only(dp[0][$ - 1 - i], dp[1][$ - 1 - i], dp[2][$ - 1 - i]).reduce!(max);
    }
    ans.writeln();
}

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