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

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

T = list(eval(input()))



ans = 0

check = {i:0 for i in range(N)}

for i in range(N):

    if i <= K-1:

        if T[i] == 'r':

            ans += P

        elif T[i] == 's':

            ans += R

        else:

            ans += S

    else:

        if T[i] != T[i-K]:

            if T[i] == 'r':

                ans += P

            elif T[i] == 's':

                ans += R

            else:

                ans += S

        elif T[i] == T[i-K] and check[i-K] == 1:

            if T[i] == 'r':

                ans += P

            elif T[i] == 's':

                ans += R   

            else:

                ans += S

        else:

            check[i] = 1



print(ans)





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

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

t = eval(input())

ans = 0

wl = [1 for i in range(k)] + [0 for j in range(n-k)]

for i in range(n):

    if i < k:

        if t[i] == 'r':

            ans += p

        elif t[i] == 's':

            ans += r

        else:

            ans += s

    else:

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

            wl[i] = 1

            if t[i] == 'r':

                ans += p

            elif t[i] == 's':

                ans += r

            else:

                ans += s

        elif wl[i-k]:

            continue

        else:

            wl[i] = 1

            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 = list(eval(input()))
ans = 0
check = {i: 0 for i in range(N)}
for i in range(N):
    if i <= K - 1:
        if T[i] == "r":
            ans += P
        elif T[i] == "s":
            ans += R
        else:
            ans += S
    else:
        if T[i] != T[i - K]:
            if T[i] == "r":
                ans += P
            elif T[i] == "s":
                ans += R
            else:
                ans += S
        elif T[i] == T[i - K] and check[i - K] == 1:
            if T[i] == "r":
                ans += P
            elif T[i] == "s":
                ans += R
            else:
                ans += S
        else:
            check[i] = 1
print(ans)

n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = eval(input())
ans = 0
wl = [1 for i in range(k)] + [0 for j in range(n - k)]
for i in range(n):
    if i < k:
        if t[i] == "r":
            ans += p
        elif t[i] == "s":
            ans += r
        else:
            ans += s
    else:
        if t[i] != t[i - k]:
            wl[i] = 1
            if t[i] == "r":
                ans += p
            elif t[i] == "s":
                ans += r
            else:
                ans += s
        elif wl[i - k]:
            continue
        else:
            wl[i] = 1
            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 = list(eval(input())) +n, k = list(map(int, input().split())) +r, s, p = list(map(int, input().split())) +t = eval(input()) -check = {i: 0 for i in range(N)} -for i in range(N): -    if i <= K - 1: -        if T[i] == "r": -            ans += P -        elif T[i] == "s": -            ans += R +wl = [1 for i in range(k)] + [0 for j in range(n - k)] +for i in range(n): +    if i < k: +        if t[i] == "r": +            ans += p +        elif t[i] == "s": +            ans += r -            ans += S +            ans += s -        if T[i] != T[i - K]: -            if T[i] == "r": -                ans += P -            elif T[i] == "s": -                ans += R +        if t[i] != t[i - k]: +            wl[i] = 1 +            if t[i] == "r": +                ans += p +            elif t[i] == "s": +                ans += r -                ans += S -        elif T[i] == T[i - K] and check[i - K] == 1: -            if T[i] == "r": -                ans += P -            elif T[i] == "s": -                ans += R +                ans += s +        elif wl[i - k]: +            continue +        else: +            wl[i] = 1 +            if t[i] == "r": +                ans += p +            elif t[i] == "s": +                ans += r -                ans += S -        else: -            check[i] = 1 +                ans += s