n,k=list(map(int,input().split()))

r,s,p=list(map(int,input().split()))

t=eval(input())

vic=""

ans=0

for i in t:

    if i=="r":

        vic+="p"

    if i=="p":

        vic+="s"

    if i=="s":

        vic+="r"

#print(vic[:k])

for i in vic[:k]:

    if i=="r":

        ans+=r

    elif i=="p":

        ans+=p

    elif i=="s":

        ans+=s

#print(vic)

#print(ans)

for i in range(k,n):

    #print(i,":",vic[i])

    if vic[i]==vic[i-k]:

        #print("lose")

        if not i==n-1:

            vic=vic[:i]+'n'+vic[i+1:]

    else:

        #print("win")

        if vic[i]=="r":

            ans+=r

        elif vic[i]=="p":

            ans+=p

        elif vic[i]=="s":

            ans+=s

        else:

            pass

            #print("wrong input")



    #print()



print(ans)
def sol(score,hand):

    if hand=="r":

        return score["p"]

    elif hand=="p":

        return score["s"]

    elif hand=="s":

        return score["r"]

    return 0

n,k=list(map(int,input().split()))

r,s,p=list(map(int,input().split()))

t=eval(input())

win=""

for num,val in enumerate(t):

    if num<k or win[num-k]!=val:

        win+=val

    else:

        win+="n"

score={"r":r,"p":p,"s":s}

ans=0

for val in win:

    ans+=sol(score,val)



print(ans)

n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = eval(input())
vic = ""
ans = 0
for i in t:
    if i == "r":
        vic += "p"
    if i == "p":
        vic += "s"
    if i == "s":
        vic += "r"
# print(vic[:k])
for i in vic[:k]:
    if i == "r":
        ans += r
    elif i == "p":
        ans += p
    elif i == "s":
        ans += s
# print(vic)
# print(ans)
for i in range(k, n):
    # print(i,":",vic[i])
    if vic[i] == vic[i - k]:
        # print("lose")
        if not i == n - 1:
            vic = vic[:i] + "n" + vic[i + 1 :]
    else:
        # print("win")
        if vic[i] == "r":
            ans += r
        elif vic[i] == "p":
            ans += p
        elif vic[i] == "s":
            ans += s
        else:
            pass
            # print("wrong input")
    # print()
print(ans)

def sol(score, hand):
    if hand == "r":
        return score["p"]
    elif hand == "p":
        return score["s"]
    elif hand == "s":
        return score["r"]
    return 0


n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = eval(input())
win = ""
for num, val in enumerate(t):
    if num < k or win[num - k] != val:
        win += val
    else:
        win += "n"
score = {"r": r, "p": p, "s": s}
ans = 0
for val in win:
    ans += sol(score, val)
print(ans)

+def sol(score, hand): +    if hand == "r": +        return score["p"] +    elif hand == "p": +        return score["s"] +    elif hand == "s": +        return score["r"] +    return 0 + + -vic = "" +win = "" +for num, val in enumerate(t): +    if num < k or win[num - k] != val: +        win += val +    else: +        win += "n" +score = {"r": r, "p": p, "s": s} -for i in t: -    if i == "r": -        vic += "p" -    if i == "p": -        vic += "s" -    if i == "s": -        vic += "r" -# print(vic[:k]) -for i in vic[:k]: -    if i == "r": -        ans += r -    elif i == "p": -        ans += p -    elif i == "s": -        ans += s -# print(vic) -# print(ans) -for i in range(k, n): -    # print(i,":",vic[i]) -    if vic[i] == vic[i - k]: -        # print("lose") -        if not i == n - 1: -            vic = vic[:i] + "n" + vic[i + 1 :] -    else: -        # print("win") -        if vic[i] == "r": -            ans += r -        elif vic[i] == "p": -            ans += p -        elif vic[i] == "s": -            ans += s -        else: -            pass -            # print("wrong input") -    # print() +for val in win: +    ans += sol(score, val)