def solve(string):

    *nkrsp, t = string.split()

    *t, = list(map(int, t.replace("r", "2").replace("s", "0").replace("p", "1")))

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

    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 * rsp[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()

    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(map(int, t.replace("r", "2").replace("s", "0").replace("p", "1")))
    n, k, *rsp = list(map(int, nkrsp))
    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 * rsp[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()
    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())))

-    (*t,) = list(map(int, t.replace("r", "2").replace("s", "0").replace("p", "1"))) +    table = {k: v for k, v in zip("spr", rsp)} -            ans += (c + 1) // 2 * rsp[u[i]] +            ans += (c + 1) // 2 * table[u[i]]