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

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

t = eval(input())



ans = 0

d = dict()

for i in range(n):

    if t[i] == "r" and d.get(i) != "r":

        ans += p

        d[i+k] = "r"

    elif t[i] == "s" and d.get(i) != "s":

        ans += r

        d[i+k] = "s"

    elif t[i] == "p" and d.get(i) != "p":

        ans += s

        d[i+k] = "p"



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

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

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

t = eval(input())



ans = 0

prev = ["#" for _ in range(k)]

for i, move in enumerate(t):

    if prev[i%k] != move:

        ans += d[move]

        prev[i%k] = move

    else:

        prev[i%k] = "#"

print(ans)    

    
n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = eval(input())
ans = 0
d = dict()
for i in range(n):
    if t[i] == "r" and d.get(i) != "r":
        ans += p
        d[i + k] = "r"
    elif t[i] == "s" and d.get(i) != "s":
        ans += r
        d[i + k] = "s"
    elif t[i] == "p" and d.get(i) != "p":
        ans += s
        d[i + k] = "p"
print(ans)

n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
d = {"r": p, "s": r, "p": s}
t = eval(input())
ans = 0
prev = ["#" for _ in range(k)]
for i, move in enumerate(t):
    if prev[i % k] != move:
        ans += d[move]
        prev[i % k] = move
    else:
        prev[i % k] = "#"
print(ans)

+d = {"r": p, "s": r, "p": s} -d = dict() -for i in range(n): -    if t[i] == "r" and d.get(i) != "r": -        ans += p -        d[i + k] = "r" -    elif t[i] == "s" and d.get(i) != "s": -        ans += r -        d[i + k] = "s" -    elif t[i] == "p" and d.get(i) != "p": -        ans += s -        d[i + k] = "p" +prev = ["#" for _ in range(k)] +for i, move in enumerate(t): +    if prev[i % k] != move: +        ans += d[move] +        prev[i % k] = move +    else: +        prev[i % k] = "#"