#N = int(input())

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

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

T = list(eval(input()))

#v =list(map(int,input().split()))

# [list(map(int,input().split())) for i in range(N)]

res =[]

answer = T.count('s')*S+T.count('p')*P+T.count('r')*R



l = [0]*N

for i in range(K,N):

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

        if T[i]==('s'):

            answer -= S

            l[i]=1

        elif T[i]==('p'):

            answer -= P

            l[i]=1

        elif T[i]==('r'):

            answer -= R

            l[i]=1



for j in range(K*2,N):

    if T[j] == T[j-K] and T[j] == T[j-K*2] and l[j-K]==1 and l[j-K*2]==0:

        if T[j]==('s'):

            answer += S

            l[j] = 0

        elif T[j]==('p'):

            answer += P

            l[j] = 0

        elif T[j]==('r'):

            answer += R

            l[j] = 0

print(answer)



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

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

T = list(eval(input()))



answer = 0

for i, t in enumerate(T):

    if t == 's':

        if i - K >= 0:

            if T[i-K] != t:

                answer += R

            else:

                T[i]=0

        else:

            answer += R

    elif t == 'p':

        if i - K >= 0:

            if T[i-K] != t:

                answer += S

            else:

                T[i]= 0

        else:

            answer += S

    elif t == 'r':

        if i - K >= 0:

            if T[i-K] != t:

                answer += P

            else:

                T[i]=0

        else:

            answer += P

    

print(answer)
# N = int(input())
N, K = list(map(int, input().split()))
S, P, R = list(map(int, input().split()))
T = list(eval(input()))
# v =list(map(int,input().split()))
# [list(map(int,input().split())) for i in range(N)]
res = []
answer = T.count("s") * S + T.count("p") * P + T.count("r") * R
l = [0] * N
for i in range(K, N):
    if T[i] == T[i - K]:
        if T[i] == ("s"):
            answer -= S
            l[i] = 1
        elif T[i] == ("p"):
            answer -= P
            l[i] = 1
        elif T[i] == ("r"):
            answer -= R
            l[i] = 1
for j in range(K * 2, N):
    if (
        T[j] == T[j - K]
        and T[j] == T[j - K * 2]
        and l[j - K] == 1
        and l[j - K * 2] == 0
    ):
        if T[j] == ("s"):
            answer += S
            l[j] = 0
        elif T[j] == ("p"):
            answer += P
            l[j] = 0
        elif T[j] == ("r"):
            answer += R
            l[j] = 0
print(answer)

N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = list(eval(input()))
answer = 0
for i, t in enumerate(T):
    if t == "s":
        if i - K >= 0:
            if T[i - K] != t:
                answer += R
            else:
                T[i] = 0
        else:
            answer += R
    elif t == "p":
        if i - K >= 0:
            if T[i - K] != t:
                answer += S
            else:
                T[i] = 0
        else:
            answer += S
    elif t == "r":
        if i - K >= 0:
            if T[i - K] != t:
                answer += P
            else:
                T[i] = 0
        else:
            answer += P
print(answer)

-# N = int(input()) -S, P, R = list(map(int, input().split())) +R, S, P = list(map(int, input().split())) -# v =list(map(int,input().split())) -# [list(map(int,input().split())) for i in range(N)] -res = [] -answer = T.count("s") * S + T.count("p") * P + T.count("r") * R -l = [0] * N -for i in range(K, N): -    if T[i] == T[i - K]: -        if T[i] == ("s"): -            answer -= S -            l[i] = 1 -        elif T[i] == ("p"): -            answer -= P -            l[i] = 1 -        elif T[i] == ("r"): -            answer -= R -            l[i] = 1 -for j in range(K * 2, N): -    if ( -        T[j] == T[j - K] -        and T[j] == T[j - K * 2] -        and l[j - K] == 1 -        and l[j - K * 2] == 0 -    ): -        if T[j] == ("s"): +answer = 0 +for i, t in enumerate(T): +    if t == "s": +        if i - K >= 0: +            if T[i - K] != t: +                answer += R +            else: +                T[i] = 0 +        else: +            answer += R +    elif t == "p": +        if i - K >= 0: +            if T[i - K] != t: +                answer += S +            else: +                T[i] = 0 +        else: -            l[j] = 0 -        elif T[j] == ("p"): +    elif t == "r": +        if i - K >= 0: +            if T[i - K] != t: +                answer += P +            else: +                T[i] = 0 +        else: -            l[j] = 0 -        elif T[j] == ("r"): -            answer += R -            l[j] = 0