import math

N, K = list(map(int, input().split()))

R, S, P = list(map(int, input().split()))

T = eval(input())

score = 0

def calc_score(a):

    ret = 0

    if a == "s":

        ret = R

    elif a == "p":

        ret = S

    elif a == "r":

        ret = P

    return ret

    

for i in range(K):

    tmp = T[i::K]

    #print(T[i::K])

    score += calc_score(tmp[0])

    flag = True

    for j in range(1,len(tmp)):

        if tmp[j] == tmp[j - 1]:

            flag = not flag

        else:

            flag = True

        if flag:

            #print(calc_score(tmp[j]))

            score += calc_score(tmp[j])

print(score)

    
import math

N, K = list(map(int, input().split()))

R, S, P = list(map(int, input().split()))

T = eval(input())

score = 0

hand = {"r":P, "s":R, "p":S}

for i in range(K):

    tmp = T[i::K]

    #print(T[i::K])

    score += hand[tmp[0]]

    flag = True

    for j in range(1,len(tmp)):

        if tmp[j] == tmp[j - 1]:

            flag = not flag

        else:

            flag = True

        if flag:

            score += hand[tmp[j]]

print(score)
import math

N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = eval(input())
score = 0


def calc_score(a):
    ret = 0
    if a == "s":
        ret = R
    elif a == "p":
        ret = S
    elif a == "r":
        ret = P
    return ret


for i in range(K):
    tmp = T[i::K]
    # print(T[i::K])
    score += calc_score(tmp[0])
    flag = True
    for j in range(1, len(tmp)):
        if tmp[j] == tmp[j - 1]:
            flag = not flag
        else:
            flag = True
        if flag:
            # print(calc_score(tmp[j]))
            score += calc_score(tmp[j])
print(score)

import math

N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = eval(input())
score = 0
hand = {"r": P, "s": R, "p": S}
for i in range(K):
    tmp = T[i::K]
    # print(T[i::K])
    score += hand[tmp[0]]
    flag = True
    for j in range(1, len(tmp)):
        if tmp[j] == tmp[j - 1]:
            flag = not flag
        else:
            flag = True
        if flag:
            score += hand[tmp[j]]
print(score)

- - -def calc_score(a): -    ret = 0 -    if a == "s": -        ret = R -    elif a == "p": -        ret = S -    elif a == "r": -        ret = P -    return ret - - +hand = {"r": P, "s": R, "p": S} -    score += calc_score(tmp[0]) +    score += hand[tmp[0]] -            # print(calc_score(tmp[j])) -            score += calc_score(tmp[j]) +            score += hand[tmp[j]]