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

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

T = list(eval(input()))

sp_T = []

for i in range(K):

    sp_T.append(T[i::K])

ans = 0

win_d = {"s": "r", "r": "p", "p": "s"}

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

for t in sp_T:

    sakki = ""

    for i in range(len(t)):

        if win_d[t[i]] != sakki:

            my_hand = win_d[t[i]]

            ans += point[my_hand]

            sakki = my_hand

        else:

            if i == len(t) - 1:

                pass

            else:

                next_want_hand = win_d[t[i + 1]]

                if sakki == next_want_hand:

                    sakki = "X"

                else:

                    sakki = "X"

print(ans)

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

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

score = {"r": P, "s": R, "p": S, "x": 0}

T = eval(input())



ans = 0



for i in range(K):

    temp = []

    for j in range(i, N, K):

        if not temp:

            temp.append(T[j])

        else:

            if temp[-1] == T[j]:

                temp.append("x")

            else:

                temp.append(T[j])

        ans += score[temp[-1]]

print(ans)
N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = list(eval(input()))
sp_T = []
for i in range(K):
    sp_T.append(T[i::K])
ans = 0
win_d = {"s": "r", "r": "p", "p": "s"}
point = {"r": R, "s": S, "p": P}
for t in sp_T:
    sakki = ""
    for i in range(len(t)):
        if win_d[t[i]] != sakki:
            my_hand = win_d[t[i]]
            ans += point[my_hand]
            sakki = my_hand
        else:
            if i == len(t) - 1:
                pass
            else:
                next_want_hand = win_d[t[i + 1]]
                if sakki == next_want_hand:
                    sakki = "X"
                else:
                    sakki = "X"
print(ans)

N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
score = {"r": P, "s": R, "p": S, "x": 0}
T = eval(input())
ans = 0
for i in range(K):
    temp = []
    for j in range(i, N, K):
        if not temp:
            temp.append(T[j])
        else:
            if temp[-1] == T[j]:
                temp.append("x")
            else:
                temp.append(T[j])
        ans += score[temp[-1]]
print(ans)

-T = list(eval(input())) -sp_T = [] +score = {"r": P, "s": R, "p": S, "x": 0} +T = eval(input()) +ans = 0 -    sp_T.append(T[i::K]) -ans = 0 -win_d = {"s": "r", "r": "p", "p": "s"} -point = {"r": R, "s": S, "p": P} -for t in sp_T: -    sakki = "" -    for i in range(len(t)): -        if win_d[t[i]] != sakki: -            my_hand = win_d[t[i]] -            ans += point[my_hand] -            sakki = my_hand +    temp = [] +    for j in range(i, N, K): +        if not temp: +            temp.append(T[j]) -            if i == len(t) - 1: -                pass +            if temp[-1] == T[j]: +                temp.append("x") -                next_want_hand = win_d[t[i + 1]] -                if sakki == next_want_hand: -                    sakki = "X" -                else: -                    sakki = "X" +                temp.append(T[j]) +        ans += score[temp[-1]]