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

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

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

T = input().strip()

hist = [0 for _ in range(N)]

ans = 0

for i in range(N):

    a = T[i]

    if hist[i]==0:

        hist[i] = 1

        cnt = 1

        j = i

        while j+K<N and T[j+K]==a:

            hist[j+K]=1

            cnt += 1

            j += K

        ans += D[a]*(cnt-cnt//2)

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

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

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

T = input().strip()

A = {i:[] for i in range(K)}

for i in range(N):

    A[i%K].append(T[i])

cnt = 0

for k in range(K):

    if len(A[k])>0:

        cnt += D[A[k][0]]

        for i in range(1,len(A[k])):

            if A[k][i]==A[k][i-1]:

                A[k][i] = 0

            elif A[k][i]!=A[k][i-1]:

                cnt += D[A[k][i]]

print(cnt)
N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
D = {"r": P, "s": R, "p": S}
T = input().strip()
hist = [0 for _ in range(N)]
ans = 0
for i in range(N):
    a = T[i]
    if hist[i] == 0:
        hist[i] = 1
        cnt = 1
        j = i
        while j + K < N and T[j + K] == a:
            hist[j + K] = 1
            cnt += 1
            j += K
        ans += D[a] * (cnt - cnt // 2)
print(ans)

N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
D = {"r": P, "s": R, "p": S}
T = input().strip()
A = {i: [] for i in range(K)}
for i in range(N):
    A[i % K].append(T[i])
cnt = 0
for k in range(K):
    if len(A[k]) > 0:
        cnt += D[A[k][0]]
        for i in range(1, len(A[k])):
            if A[k][i] == A[k][i - 1]:
                A[k][i] = 0
            elif A[k][i] != A[k][i - 1]:
                cnt += D[A[k][i]]
print(cnt)

-hist = [0 for _ in range(N)] -ans = 0 +A = {i: [] for i in range(K)} -    a = T[i] -    if hist[i] == 0: -        hist[i] = 1 -        cnt = 1 -        j = i -        while j + K < N and T[j + K] == a: -            hist[j + K] = 1 -            cnt += 1 -            j += K -        ans += D[a] * (cnt - cnt // 2) -print(ans) +    A[i % K].append(T[i]) +cnt = 0 +for k in range(K): +    if len(A[k]) > 0: +        cnt += D[A[k][0]] +        for i in range(1, len(A[k])): +            if A[k][i] == A[k][i - 1]: +                A[k][i] = 0 +            elif A[k][i] != A[k][i - 1]: +                cnt += D[A[k][i]] +print(cnt)