N, K = list(map(int, input().split()))

R, S, P = list(map(int, input().split()))

T = eval(input())



dp = [False] * N



for i in range(N):

    if i >= K and dp[i - K] and T[i] == T[i - K]:

        continue

    dp[i] = True

    

ans = 0

for i in range(N):

    if not dp[i]:

        continue

        

    if T[i] == "r":

        ans += P

    elif T[i] == "s":

        ans += R

    else:

        ans += S

        

print(ans)

N, K = list(map(int, input().split()))

R, S, P = list(map(int, input().split()))

T = eval(input())





ok = [True] * N

d = {"r": P, "s": R, "p": S}

ans = 0

for i in range(N):

    if i >= K and T[i - K] == T[i] and ok[i - K]:

        ok[i] = False

    if ok[i]:

        ans += d[T[i]]

print(ans)

N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = eval(input())
dp = [False] * N
for i in range(N):
    if i >= K and dp[i - K] and T[i] == T[i - K]:
        continue
    dp[i] = True
ans = 0
for i in range(N):
    if not dp[i]:
        continue
    if T[i] == "r":
        ans += P
    elif T[i] == "s":
        ans += R
    else:
        ans += S
print(ans)

N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = eval(input())
ok = [True] * N
d = {"r": P, "s": R, "p": S}
ans = 0
for i in range(N):
    if i >= K and T[i - K] == T[i] and ok[i - K]:
        ok[i] = False
    if ok[i]:
        ans += d[T[i]]
print(ans)

-dp = [False] * N -for i in range(N): -    if i >= K and dp[i - K] and T[i] == T[i - K]: -        continue -    dp[i] = True +ok = [True] * N +d = {"r": P, "s": R, "p": S} -    if not dp[i]: -        continue -    if T[i] == "r": -        ans += P -    elif T[i] == "s": -        ans += R -    else: -        ans += S +    if i >= K and T[i - K] == T[i] and ok[i - K]: +        ok[i] = False +    if ok[i]: +        ans += d[T[i]]