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

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

T =list(eval(input()))



ans =0

for i in range(N):

    if i<K:

        if T[i]=="r":

            ans+=P

        elif T[i]=="s":

            ans+=R

        else:

            ans+=S

            

    else:

        if T[i]=="r":

            if T[i-K]!="r":

                ans+=P

            else:

                T[i]="-"

        elif T[i]=="s":

            if T[i-K]!="s":

                ans+=R

            else:

                T[i]="-"

        else:

            if T[i]=="p":

                if T[i-K]!="p":

                    ans+=S

                else:

                    T[i]="-"

print(ans)


def I(): return int(eval(input()))

def MI(): return list(map(int, input().split()))

def LI(): return list(map(int, input().split()))



def main():

    mod=10**9+7

    N,K=MI()

    R,S,P=MI()

    T=eval(input())

    L=[]

    

    ans=0

    for i in range(N):

        pre="z"

        if i-K>=0:

            pre=L[i-K]

            

        if T[i]=="r":

            if pre!="p":

                ans+=P

                L.append("p")

            else:

                L.append("z")

                

        if T[i]=="s":

            if pre!="r":

                ans+=R

                L.append("r")

            else:

                L.append("z")



        if T[i]=="p":

            if pre!="s":

                ans+=S

                L.append("s")

            else:

                L.append("z")

                

    print(ans)

                

    



main()

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

def I():
    return int(eval(input()))


def MI():
    return list(map(int, input().split()))


def LI():
    return list(map(int, input().split()))


def main():
    mod = 10**9 + 7
    N, K = MI()
    R, S, P = MI()
    T = eval(input())
    L = []
    ans = 0
    for i in range(N):
        pre = "z"
        if i - K >= 0:
            pre = L[i - K]
        if T[i] == "r":
            if pre != "p":
                ans += P
                L.append("p")
            else:
                L.append("z")
        if T[i] == "s":
            if pre != "r":
                ans += R
                L.append("r")
            else:
                L.append("z")
        if T[i] == "p":
            if pre != "s":
                ans += S
                L.append("s")
            else:
                L.append("z")
    print(ans)


main()

-N, K = list(map(int, input().split())) -R, S, P = list(map(int, input().split())) -T = list(eval(input())) -ans = 0 -for i in range(N): -    if i < K: +def I(): +    return int(eval(input())) + + +def MI(): +    return list(map(int, input().split())) + + +def LI(): +    return list(map(int, input().split())) + + +def main(): +    mod = 10**9 + 7 +    N, K = MI() +    R, S, P = MI() +    T = eval(input()) +    L = [] +    ans = 0 +    for i in range(N): +        pre = "z" +        if i - K >= 0: +            pre = L[i - K] -            ans += P -        elif T[i] == "s": -            ans += R -        else: -            ans += S -    else: -        if T[i] == "r": -            if T[i - K] != "r": +            if pre != "p": +                L.append("p") -                T[i] = "-" -        elif T[i] == "s": -            if T[i - K] != "s": +                L.append("z") +        if T[i] == "s": +            if pre != "r": +                L.append("r") -                T[i] = "-" -        else: -            if T[i] == "p": -                if T[i - K] != "p": -                    ans += S -                else: -                    T[i] = "-" -print(ans) +                L.append("z") +        if T[i] == "p": +            if pre != "s": +                ans += S +                L.append("s") +            else: +                L.append("z") +    print(ans) + + +main()