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

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

t = eval(input())



cnt, ans = set(), 0

for i, ti in enumerate(t):

    if (i - k in cnt) and ti == t[i - k]:

        continue

    ans += r * (ti == 's')

    ans += s * (ti == 'p')

    ans += p * (ti == 'r')

    cnt.add(i)

print(ans)

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

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

t = eval(input())



dict = {'s': r, 'p': s, 'r': p}

cnt, ans = set(), 0

for i, ti in enumerate(t):

    if (i - k in cnt) and ti == t[i - k]:

        continue

    ans += dict[ti]

    cnt.add(i)

print(ans)

n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = eval(input())
cnt, ans = set(), 0
for i, ti in enumerate(t):
    if (i - k in cnt) and ti == t[i - k]:
        continue
    ans += r * (ti == "s")
    ans += s * (ti == "p")
    ans += p * (ti == "r")
    cnt.add(i)
print(ans)

n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = eval(input())
dict = {"s": r, "p": s, "r": p}
cnt, ans = set(), 0
for i, ti in enumerate(t):
    if (i - k in cnt) and ti == t[i - k]:
        continue
    ans += dict[ti]
    cnt.add(i)
print(ans)

+dict = {"s": r, "p": s, "r": p} -    ans += r * (ti == "s") -    ans += s * (ti == "p") -    ans += p * (ti == "r") +    ans += dict[ti]