import copy

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

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

T = list(eval(input()))



mo = [[] for i in range(k)]



for i in range(n):

    num = i % k

    mo[num].append(T[i])

    

mo1 = copy.deepcopy(mo)

for i in range(k): 

    for j in range(len(mo[i])):

        if mo[i][j] == "r":

            mo1[i][j] = "p"

        elif mo[i][j] == "p":

            mo1[i][j] = "s"

        else:

            mo1[i][j] = "r"

        if j > 0 and mo1[i][j] == mo1[i][j-1]:

            mo1[i][j] = "x"



ans = 0

for i in range(k):

    for j in range(len(mo1[i])):

        if mo1[i][j] == "r":

            ans += r

        elif mo1[i][j] == "p":

            ans += p

        elif mo1[i][j] == "s":

            ans += s

print(ans)
import copy

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

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

T = list(eval(input()))



for i in range(n-k):

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

        T[i+k] = "x"

cr = T.count("r")

cp = T.count("p")

cs = T.count("s")

print((cp*s+cr*p+cs*r))



import copy

n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
T = list(eval(input()))
mo = [[] for i in range(k)]
for i in range(n):
    num = i % k
    mo[num].append(T[i])
mo1 = copy.deepcopy(mo)
for i in range(k):
    for j in range(len(mo[i])):
        if mo[i][j] == "r":
            mo1[i][j] = "p"
        elif mo[i][j] == "p":
            mo1[i][j] = "s"
        else:
            mo1[i][j] = "r"
        if j > 0 and mo1[i][j] == mo1[i][j - 1]:
            mo1[i][j] = "x"
ans = 0
for i in range(k):
    for j in range(len(mo1[i])):
        if mo1[i][j] == "r":
            ans += r
        elif mo1[i][j] == "p":
            ans += p
        elif mo1[i][j] == "s":
            ans += s
print(ans)

import copy

n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
T = list(eval(input()))
for i in range(n - k):
    if T[i] == T[i + k]:
        T[i + k] = "x"
cr = T.count("r")
cp = T.count("p")
cs = T.count("s")
print((cp * s + cr * p + cs * r))

-mo = [[] for i in range(k)] -for i in range(n): -    num = i % k -    mo[num].append(T[i]) -mo1 = copy.deepcopy(mo) -for i in range(k): -    for j in range(len(mo[i])): -        if mo[i][j] == "r": -            mo1[i][j] = "p" -        elif mo[i][j] == "p": -            mo1[i][j] = "s" -        else: -            mo1[i][j] = "r" -        if j > 0 and mo1[i][j] == mo1[i][j - 1]: -            mo1[i][j] = "x" -ans = 0 -for i in range(k): -    for j in range(len(mo1[i])): -        if mo1[i][j] == "r": -            ans += r -        elif mo1[i][j] == "p": -            ans += p -        elif mo1[i][j] == "s": -            ans += s -print(ans) +for i in range(n - k): +    if T[i] == T[i + k]: +        T[i + k] = "x" +cr = T.count("r") +cp = T.count("p") +cs = T.count("s") +print((cp * s + cr * p + cs * r))