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

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

st=eval(input())

for i in range(len(st)-1):

    if i + k > len(st)-1:

        break

    elif st[i] == st[i+k]:

        st = st[:i+k]+'n'+st[i+k+1:]

win = r*st.count('s')+s*st.count('p')+p*st.count('r')

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

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

st=list(eval(input()))

for i in range(n-k):

    if st[i] == st[i+k]:

        st[i+k] = 'no'

win = r*st.count('s')+s*st.count('p')+p*st.count('r')

print(win)
n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
st = eval(input())
for i in range(len(st) - 1):
    if i + k > len(st) - 1:
        break
    elif st[i] == st[i + k]:
        st = st[: i + k] + "n" + st[i + k + 1 :]
win = r * st.count("s") + s * st.count("p") + p * st.count("r")
print(win)

n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
st = list(eval(input()))
for i in range(n - k):
    if st[i] == st[i + k]:
        st[i + k] = "no"
win = r * st.count("s") + s * st.count("p") + p * st.count("r")
print(win)

-st = eval(input()) -for i in range(len(st) - 1): -    if i + k > len(st) - 1: -        break -    elif st[i] == st[i + k]: -        st = st[: i + k] + "n" + st[i + k + 1 :] +st = list(eval(input())) +for i in range(n - k): +    if st[i] == st[i + k]: +        st[i + k] = "no"