# -*- coding: utf-8 -*-



################ DANGER ################

test = ""

#test = \

"""

5 2

8 7 6

rsrpr

ans 27

"""



"""

7 1

100 10 1

ssssppr

ans 211

"""



"""

30 5

325 234 123

rspsspspsrpspsppprpsprpssprpsr

ans 4996

"""

########################################

test = list(reversed(test.strip().splitlines()))

if test:

    def input2():

        return test.pop()

else:

    def input2():

        return eval(input())

########################################  

        

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

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

t = list(input2())



rsp = {"r", "s", "p"}



for i in range(k, n-1):

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

        t[i] = rsp - {t[i], t[i+1]}

        

if t[n-1] == t[n-1-k]:

    t[n-1] = rsp - {t[n-1]}



ans = (t.count("r") * p +

       t.count("s") * r +

       t.count("p") * s)



print(ans)



from array import array

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

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

t = array("u", list(eval(input())))



for i in range(k, n-1):

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

        t[i] = "*"

        

if t[n-1] == t[n-1-k]:

    t[n-1] = "*"



ans = (t.count("r") * p +

       t.count("s") * r +

       t.count("p") * s)



print(ans)
# -*- coding: utf-8 -*-
################ DANGER ################
test = ""
# test = \
"""
5 2
8 7 6
rsrpr
ans 27
"""
"""
7 1
100 10 1
ssssppr
ans 211
"""
"""
30 5
325 234 123
rspsspspsrpspsppprpsprpssprpsr
ans 4996
"""
########################################
test = list(reversed(test.strip().splitlines()))
if test:

    def input2():
        return test.pop()

else:

    def input2():
        return eval(input())


########################################
n, k = list(map(int, input2().split()))
r, s, p = list(map(int, input2().split()))
t = list(input2())
rsp = {"r", "s", "p"}
for i in range(k, n - 1):
    if t[i] == t[i - k]:
        t[i] = rsp - {t[i], t[i + 1]}
if t[n - 1] == t[n - 1 - k]:
    t[n - 1] = rsp - {t[n - 1]}
ans = t.count("r") * p + t.count("s") * r + t.count("p") * s
print(ans)

from array import array

n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = array("u", list(eval(input())))
for i in range(k, n - 1):
    if t[i] == t[i - k]:
        t[i] = "*"
if t[n - 1] == t[n - 1 - k]:
    t[n - 1] = "*"
ans = t.count("r") * p + t.count("s") * r + t.count("p") * s
print(ans)

-# -*- coding: utf-8 -*- -################ DANGER ################ -test = "" -# test = \ -""" -5 2 -8 7 6 -rsrpr -ans 27 -""" -""" -7 1 -100 10 1 -ssssppr -ans 211 -""" -""" -30 5 -325 234 123 -rspsspspsrpspsppprpsprpssprpsr -ans 4996 -""" -######################################## -test = list(reversed(test.strip().splitlines())) -if test: +from array import array -    def input2(): -        return test.pop() - -else: - -    def input2(): -        return eval(input()) - - -######################################## -n, k = list(map(int, input2().split())) -r, s, p = list(map(int, input2().split())) -t = list(input2()) -rsp = {"r", "s", "p"} +n, k = list(map(int, input().split())) +r, s, p = list(map(int, input().split())) +t = array("u", list(eval(input()))) -        t[i] = rsp - {t[i], t[i + 1]} +        t[i] = "*" -    t[n - 1] = rsp - {t[n - 1]} +    t[n - 1] = "*"