from itertools import groupby



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

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

t = list(eval(input()))



point = 0



for i in range(k):

    li = ["x"]+t[i::k]

    for j in range(1,len(li)):

        if li[j-1] == li[j]:

            li[j] = "x"

            continue

        if li[j] == "r":

            point += p

        elif li[j] == "s":

            point += r

        else:

            point += s

    

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

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

t = list(eval(input()))

point = 0



for i in t[:k]:

    if i == "r":

        point += p

    elif i == "s":

        point += r

    else:

        point += s



for i in range(k,n):

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

        t[i] = "x"

        continue

    if t[i] == "r":

        point += p

    elif t[i] == "s":

        point += r

    else:

        point += s



print(point)
from itertools import groupby

n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = list(eval(input()))
point = 0
for i in range(k):
    li = ["x"] + t[i::k]
    for j in range(1, len(li)):
        if li[j - 1] == li[j]:
            li[j] = "x"
            continue
        if li[j] == "r":
            point += p
        elif li[j] == "s":
            point += r
        else:
            point += s
print(point)

n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = list(eval(input()))
point = 0
for i in t[:k]:
    if i == "r":
        point += p
    elif i == "s":
        point += r
    else:
        point += s
for i in range(k, n):
    if t[i - k] == t[i]:
        t[i] = "x"
        continue
    if t[i] == "r":
        point += p
    elif t[i] == "s":
        point += r
    else:
        point += s
print(point)

-from itertools import groupby - -for i in range(k): -    li = ["x"] + t[i::k] -    for j in range(1, len(li)): -        if li[j - 1] == li[j]: -            li[j] = "x" -            continue -        if li[j] == "r": -            point += p -        elif li[j] == "s": -            point += r -        else: -            point += s +for i in t[:k]: +    if i == "r": +        point += p +    elif i == "s": +        point += r +    else: +        point += s +for i in range(k, n): +    if t[i - k] == t[i]: +        t[i] = "x" +        continue +    if t[i] == "r": +        point += p +    elif t[i] == "s": +        point += r +    else: +        point += s