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

get_score=list(map(int,input().split()))

t=list(eval(input()))

dic={'r':0,'s':1,'p':2}



ans=0

for i in range(n):

    if t[i]=='D':continue

    if i+k<n and t[i]==t[i+k]:

        t[i+k]='D'

    ans+=get_score[(dic[t[i]]+2)%3]



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

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

t = list(eval(input()))



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

score = 0

for i in range(n):

    if t[i] == 0:continue

    score += dic[t[i]]

    if i + k < n and t[i + k] == t[i]:

        t[i + k] = 0

print(score)
n, k = list(map(int, input().split()))
get_score = list(map(int, input().split()))
t = list(eval(input()))
dic = {"r": 0, "s": 1, "p": 2}
ans = 0
for i in range(n):
    if t[i] == "D":
        continue
    if i + k < n and t[i] == t[i + k]:
        t[i + k] = "D"
    ans += get_score[(dic[t[i]] + 2) % 3]
print(ans)

n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = list(eval(input()))
dic = {"r": p, "s": r, "p": s}
score = 0
for i in range(n):
    if t[i] == 0:
        continue
    score += dic[t[i]]
    if i + k < n and t[i + k] == t[i]:
        t[i + k] = 0
print(score)

-get_score = list(map(int, input().split())) +r, s, p = list(map(int, input().split())) -dic = {"r": 0, "s": 1, "p": 2} -ans = 0 +dic = {"r": p, "s": r, "p": s} +score = 0 -    if t[i] == "D": +    if t[i] == 0: -    if i + k < n and t[i] == t[i + k]: -        t[i + k] = "D" -    ans += get_score[(dic[t[i]] + 2) % 3] -print(ans) +    score += dic[t[i]] +    if i + k < n and t[i + k] == t[i]: +        t[i + k] = 0 +print(score)