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

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

T = eval(input())

L = [[] for _ in range(K)]

for i in range(N):

    j = i % K

    L[j].append(T[i])

ans = 0

for i in range(K):

    for j in range(len(L[i])-1):

        if L[i][j] == L[i][j+1]:

            L[i][j+1] = 0

        if L[i][j] == 'r':

            L[i][j] = P

        if L[i][j] == 's':

            L[i][j] = R

        if L[i][j] == 'p':

            L[i][j] = S

    if L[i][-1] == 'r':

        L[i][-1] = P

    elif L[i][-1] == 's':

        L[i][-1] = R

    elif L[i][-1] == 'p':

        L[i][-1] = S

    ans += sum(L[i])

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

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

T = eval(input())

L = []

for i in range(N):

    L.append(T[i])

for i in range(N-K):

    if L[i] == L[i+K]:

        L[i+K] = 0

for i in range(N):

    if L[i] == 'r':

        L[i] = P

    elif L[i] == 's':

        L[i] = R

    elif L[i] == 'p':

        L[i] = S

print((sum(L)))
N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = eval(input())
L = [[] for _ in range(K)]
for i in range(N):
    j = i % K
    L[j].append(T[i])
ans = 0
for i in range(K):
    for j in range(len(L[i]) - 1):
        if L[i][j] == L[i][j + 1]:
            L[i][j + 1] = 0
        if L[i][j] == "r":
            L[i][j] = P
        if L[i][j] == "s":
            L[i][j] = R
        if L[i][j] == "p":
            L[i][j] = S
    if L[i][-1] == "r":
        L[i][-1] = P
    elif L[i][-1] == "s":
        L[i][-1] = R
    elif L[i][-1] == "p":
        L[i][-1] = S
    ans += sum(L[i])
print(ans)

N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = eval(input())
L = []
for i in range(N):
    L.append(T[i])
for i in range(N - K):
    if L[i] == L[i + K]:
        L[i + K] = 0
for i in range(N):
    if L[i] == "r":
        L[i] = P
    elif L[i] == "s":
        L[i] = R
    elif L[i] == "p":
        L[i] = S
print((sum(L)))

-L = [[] for _ in range(K)] +L = [] -    j = i % K -    L[j].append(T[i]) -ans = 0 -for i in range(K): -    for j in range(len(L[i]) - 1): -        if L[i][j] == L[i][j + 1]: -            L[i][j + 1] = 0 -        if L[i][j] == "r": -            L[i][j] = P -        if L[i][j] == "s": -            L[i][j] = R -        if L[i][j] == "p": -            L[i][j] = S -    if L[i][-1] == "r": -        L[i][-1] = P -    elif L[i][-1] == "s": -        L[i][-1] = R -    elif L[i][-1] == "p": -        L[i][-1] = S -    ans += sum(L[i]) -print(ans) +    L.append(T[i]) +for i in range(N - K): +    if L[i] == L[i + K]: +        L[i + K] = 0 +for i in range(N): +    if L[i] == "r": +        L[i] = P +    elif L[i] == "s": +        L[i] = R +    elif L[i] == "p": +        L[i] = S +print((sum(L)))