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

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

T=list(eval(input()))



score={'r':P,'s':R,'p':S}



ans=0

for i in range(K):

  ans += score[T[i]]



for i in range(K,N):

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

    T[i] = ''

    continue

  ans += score[T[i]]



print(ans)
def resolve():

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

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

    T = list(eval(input()))

 

    score = {'r':  P, 's': R, 'p': S}

 

    ans = 0

    for i in range(K):

        ans += score[T[i]]

 

    for i in range(K, N):

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

            T[i] = ' '

            continue

        ans += score[T[i]]

 

    print(ans)

 

if __name__ == "__main__":

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

def resolve():
    N, K = list(map(int, input().split()))
    R, S, P = list(map(int, input().split()))
    T = list(eval(input()))
    score = {"r": P, "s": R, "p": S}
    ans = 0
    for i in range(K):
        ans += score[T[i]]
    for i in range(K, N):
        if T[i - K] == T[i]:
            T[i] = " "
            continue
        ans += score[T[i]]
    print(ans)


if __name__ == "__main__":
    resolve()

-N, K = list(map(int, input().split())) -R, S, P = list(map(int, input().split())) -T = list(eval(input())) -score = {"r": P, "s": R, "p": S} -ans = 0 -for i in range(K): -    ans += score[T[i]] -for i in range(K, N): -    if T[i - K] == T[i]: -        T[i] = "" -        continue -    ans += score[T[i]] -print(ans) +def resolve(): +    N, K = list(map(int, input().split())) +    R, S, P = list(map(int, input().split())) +    T = list(eval(input())) +    score = {"r": P, "s": R, "p": S} +    ans = 0 +    for i in range(K): +        ans += score[T[i]] +    for i in range(K, N): +        if T[i - K] == T[i]: +            T[i] = " " +            continue +        ans += score[T[i]] +    print(ans) + + +if __name__ == "__main__": +    resolve()