n, k = list(map(int, input().split()))

r, s, p = list(map(int, input().split()))

t = str(eval(input()))



ans = 0

te = ["" for _ in range(n)]

for i in range(n):

	if t[i] == "r" and te[i - k] != "p":

		ans += p

		te[i] = "p"

	elif t[i] == "s" and te[i - k] != "r":

		ans += r

		te[i] = "r"

	elif t[i] == "p" and te[i - k] != "s":

		ans += s

		te[i] = "s"



print(ans)
import sys



sys.setrecursionlimit(10 ** 7)

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

    n, k = list(map(int, input().split()))

    r, s, p = list(map(int, input().split()))

    t = list(eval(input()))



    res = 0

    for i in range(n):

        if i < k:

            res += p if t[i] == "r" else r if t[i] == "s" else s

        else:

            if t[i - k] != t[i]:

                res += p if t[i] == "r" else r if t[i] == "s" else s

            else:

                t[i] = "e"



    print(res)





if __name__ == '__main__':

    resolve()

n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = str(eval(input()))
ans = 0
te = ["" for _ in range(n)]
for i in range(n):
    if t[i] == "r" and te[i - k] != "p":
        ans += p
        te[i] = "p"
    elif t[i] == "s" and te[i - k] != "r":
        ans += r
        te[i] = "r"
    elif t[i] == "p" and te[i - k] != "s":
        ans += s
        te[i] = "s"
print(ans)

import sys

sys.setrecursionlimit(10**7)
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    n, k = list(map(int, input().split()))
    r, s, p = list(map(int, input().split()))
    t = list(eval(input()))
    res = 0
    for i in range(n):
        if i < k:
            res += p if t[i] == "r" else r if t[i] == "s" else s
        else:
            if t[i - k] != t[i]:
                res += p if t[i] == "r" else r if t[i] == "s" else s
            else:
                t[i] = "e"
    print(res)


if __name__ == "__main__":
    resolve()

-n, k = list(map(int, input().split())) -r, s, p = list(map(int, input().split())) -t = str(eval(input())) -ans = 0 -te = ["" for _ in range(n)] -for i in range(n): -    if t[i] == "r" and te[i - k] != "p": -        ans += p -        te[i] = "p" -    elif t[i] == "s" and te[i - k] != "r": -        ans += r -        te[i] = "r" -    elif t[i] == "p" and te[i - k] != "s": -        ans += s -        te[i] = "s" -print(ans) +import sys + +sys.setrecursionlimit(10**7) +f_inf = float("inf") +mod = 10**9 + 7 + + +def resolve(): +    n, k = list(map(int, input().split())) +    r, s, p = list(map(int, input().split())) +    t = list(eval(input())) +    res = 0 +    for i in range(n): +        if i < k: +            res += p if t[i] == "r" else r if t[i] == "s" else s +        else: +            if t[i - k] != t[i]: +                res += p if t[i] == "r" else r if t[i] == "s" else s +            else: +                t[i] = "e" +    print(res) + + +if __name__ == "__main__": +    resolve()