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

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

T=list(eval(input()))



row=[]

for i in range(K):

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

  

score=0

for r in row:

  pre="n"

  for i, hand in enumerate(r):

    if hand==pre:

      pre=0

    else:

      if hand=="r":

        score+=P

        pre="r"

      elif hand=="s":

        score+=R

        pre="s"

      else:

        score+=S

        pre="p"

        

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

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

T=list(eval(input()))

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

result=["none"]*N

ans=0

for i in range(N):

    if i<K:

        ans+=D[T[i]]

        result[i]=T[i]

    else:

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

            ans+=D[T[i]]

            result[i]=T[i]

print(ans)
N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = list(eval(input()))
row = []
for i in range(K):
    row.append(T[i::K])
score = 0
for r in row:
    pre = "n"
    for i, hand in enumerate(r):
        if hand == pre:
            pre = 0
        else:
            if hand == "r":
                score += P
                pre = "r"
            elif hand == "s":
                score += R
                pre = "s"
            else:
                score += S
                pre = "p"
print(score)

N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = list(eval(input()))
D = {"r": P, "s": R, "p": S}
result = ["none"] * N
ans = 0
for i in range(N):
    if i < K:
        ans += D[T[i]]
        result[i] = T[i]
    else:
        if T[i] != result[i - K]:
            ans += D[T[i]]
            result[i] = T[i]
print(ans)

-row = [] -for i in range(K): -    row.append(T[i::K]) -score = 0 -for r in row: -    pre = "n" -    for i, hand in enumerate(r): -        if hand == pre: -            pre = 0 -        else: -            if hand == "r": -                score += P -                pre = "r" -            elif hand == "s": -                score += R -                pre = "s" -            else: -                score += S -                pre = "p" -print(score) +D = {"r": P, "s": R, "p": S} +result = ["none"] * N +ans = 0 +for i in range(N): +    if i < K: +        ans += D[T[i]] +        result[i] = T[i] +    else: +        if T[i] != result[i - K]: +            ans += D[T[i]] +            result[i] = T[i] +print(ans)