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

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

T = eval(input())

check = [0]*N

ans = 0

for i in range(N):

    if i < K or T[i] != T[i-K] or not check[i-K]:

        ans += P if T[i] == 'r' else R if T[i] == 's' else S

        check[i] = 1

print(ans)


def solve(N,K,R,S,P,T):

    check = [0]*N

    ans = 0

    for i in range(N):

        if i < K or T[i] != T[i-K] or not check[i-K]:

            ans += P if T[i] == 'r' else R if T[i] == 's' else S

            check[i] = 1

    print(ans)



def main():

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

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

    T = eval(input())

    solve(N,K,R,S,P,T)



if __name__ == "__main__":

    main()
N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = eval(input())
check = [0] * N
ans = 0
for i in range(N):
    if i < K or T[i] != T[i - K] or not check[i - K]:
        ans += P if T[i] == "r" else R if T[i] == "s" else S
        check[i] = 1
print(ans)

def solve(N, K, R, S, P, T):
    check = [0] * N
    ans = 0
    for i in range(N):
        if i < K or T[i] != T[i - K] or not check[i - K]:
            ans += P if T[i] == "r" else R if T[i] == "s" else S
            check[i] = 1
    print(ans)


def main():
    N, K = list(map(int, input().split()))
    R, S, P = list(map(int, input().split()))
    T = eval(input())
    solve(N, K, R, S, P, T)


if __name__ == "__main__":
    main()

-N, K = list(map(int, input().split())) -R, S, P = list(map(int, input().split())) -T = eval(input()) -check = [0] * N -ans = 0 -for i in range(N): -    if i < K or T[i] != T[i - K] or not check[i - K]: -        ans += P if T[i] == "r" else R if T[i] == "s" else S -        check[i] = 1 -print(ans) +def solve(N, K, R, S, P, T): +    check = [0] * N +    ans = 0 +    for i in range(N): +        if i < K or T[i] != T[i - K] or not check[i - K]: +            ans += P if T[i] == "r" else R if T[i] == "s" else S +            check[i] = 1 +    print(ans) + + +def main(): +    N, K = list(map(int, input().split())) +    R, S, P = list(map(int, input().split())) +    T = eval(input()) +    solve(N, K, R, S, P, T) + + +if __name__ == "__main__": +    main()