import sys



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

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

t = eval(input())



win_choice = {'s':'r', 'p':'s', 'r':'p'}

janken_point = {'r':r, 's':s, 'p':p}



dp = []

# a: 相手の手, x:自分が出せない手

def point(a, x=None):

    if x == win_choice[a]: return 0

    else: return janken_point[win_choice[a]]



score = 0

flag = [('0', 1)] * k

for i in range(n):

    if flag[i % k][0] != t[i]:

        score += point(t[i])

        flag[i % k] = (t[i], -1)

    elif flag[i % k][0] == t[i] and flag[i % k][1] == 1:

        score += point(t[i])

        flag[i % k] = (t[i], -1)

    else:

        flag[i % k] = (t[i], 1)



print(score)

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

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

t = eval(input())



point = {'s':r, 'p':s, 'r':p}



score = 0

flag = [('0', 1)] * k

for i in range(n):

    if flag[i % k][0] != t[i]:

        score += point[t[i]]

        flag[i % k] = (t[i], -1)

    elif flag[i % k][0] == t[i] and flag[i % k][1] == 1:

        score += point[t[i]]

        flag[i % k] = (t[i], -1)

    else:

        flag[i % k] = (t[i], 1)



print(score)
import sys

n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = eval(input())
win_choice = {"s": "r", "p": "s", "r": "p"}
janken_point = {"r": r, "s": s, "p": p}
dp = []
# a: 相手の手, x:自分が出せない手
def point(a, x=None):
    if x == win_choice[a]:
        return 0
    else:
        return janken_point[win_choice[a]]


score = 0
flag = [("0", 1)] * k
for i in range(n):
    if flag[i % k][0] != t[i]:
        score += point(t[i])
        flag[i % k] = (t[i], -1)
    elif flag[i % k][0] == t[i] and flag[i % k][1] == 1:
        score += point(t[i])
        flag[i % k] = (t[i], -1)
    else:
        flag[i % k] = (t[i], 1)
print(score)

n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = eval(input())
point = {"s": r, "p": s, "r": p}
score = 0
flag = [("0", 1)] * k
for i in range(n):
    if flag[i % k][0] != t[i]:
        score += point[t[i]]
        flag[i % k] = (t[i], -1)
    elif flag[i % k][0] == t[i] and flag[i % k][1] == 1:
        score += point[t[i]]
        flag[i % k] = (t[i], -1)
    else:
        flag[i % k] = (t[i], 1)
print(score)

-import sys - -win_choice = {"s": "r", "p": "s", "r": "p"} -janken_point = {"r": r, "s": s, "p": p} -dp = [] -# a: 相手の手, x:自分が出せない手 -def point(a, x=None): -    if x == win_choice[a]: -        return 0 -    else: -        return janken_point[win_choice[a]] - - +point = {"s": r, "p": s, "r": p} -        score += point(t[i]) +        score += point[t[i]] -        score += point(t[i]) +        score += point[t[i]]