def solve(string):

    *nkrsp, t = string.split()

    n, k, *rsp = list(map(int, nkrsp))

    table = {k: v for k, v in zip("spr", rsp)}

    ans = 0

    for s in range(k):

        u = t[s::k]

        i = 0

        while i < len(u):

            c = 1

            while i < len(u) - 1 and u[i] == u[i + 1]:

                i += 1

                c += 1

            ans += (c + 1) // 2 * table[u[i]]

            i += 1

    return str(ans)





if __name__ == '__main__':

    import sys

    print((solve(sys.stdin.read().strip())))

def solve(string):

    *nkrsp, t = string.split()

    t = list(t)

    n, k, *rsp = list(map(int, nkrsp))

    b = {k: v for k, v in zip("spr", rsp)}

    ans = sum([b[k] for k in t[:k]])

    for i, _t in enumerate(t[k:]):

        if _t == t[i]:

            t[i + k] = "x"

        else:

            ans += b[_t]

    return str(ans)





if __name__ == '__main__':

    import sys

    print((solve(sys.stdin.read().strip())))

def solve(string):
    *nkrsp, t = string.split()
    n, k, *rsp = list(map(int, nkrsp))
    table = {k: v for k, v in zip("spr", rsp)}
    ans = 0
    for s in range(k):
        u = t[s::k]
        i = 0
        while i < len(u):
            c = 1
            while i < len(u) - 1 and u[i] == u[i + 1]:
                i += 1
                c += 1
            ans += (c + 1) // 2 * table[u[i]]
            i += 1
    return str(ans)


if __name__ == "__main__":
    import sys

    print((solve(sys.stdin.read().strip())))

def solve(string):
    *nkrsp, t = string.split()
    t = list(t)
    n, k, *rsp = list(map(int, nkrsp))
    b = {k: v for k, v in zip("spr", rsp)}
    ans = sum([b[k] for k in t[:k]])
    for i, _t in enumerate(t[k:]):
        if _t == t[i]:
            t[i + k] = "x"
        else:
            ans += b[_t]
    return str(ans)


if __name__ == "__main__":
    import sys

    print((solve(sys.stdin.read().strip())))

+    t = list(t) -    table = {k: v for k, v in zip("spr", rsp)} -    ans = 0 -    for s in range(k): -        u = t[s::k] -        i = 0 -        while i < len(u): -            c = 1 -            while i < len(u) - 1 and u[i] == u[i + 1]: -                i += 1 -                c += 1 -            ans += (c + 1) // 2 * table[u[i]] -            i += 1 +    b = {k: v for k, v in zip("spr", rsp)} +    ans = sum([b[k] for k in t[:k]]) +    for i, _t in enumerate(t[k:]): +        if _t == t[i]: +            t[i + k] = "x" +        else: +            ans += b[_t]