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

R,S,P=list(map(int,input().split())) #RSP グーチョキパー

T=list(eval(input()))



c=0



def jan(a):

    if a=="r":

        return P

    elif a=="s":

        return R

    elif a=="p":

        return S

    else:

        return 0



for i in range(K,N):

    if T[i-K]==T[i]:

        T[i]="o"



for i in range(1,K+1): #modK

    for j in range(N//K+1):

        if i+K*j>N:

            continue

        c+=jan(T[i+K*j-1])



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

R,S,P=list(map(int,input().split())) #RSP グーチョキパー

T=list(eval(input()))



c=0



def jan(a):

    if a=="r":

        return P

    elif a=="s":

        return R

    elif a=="p":

        return S

    else:

        return 0



for i in range(K,N):

    if T[i-K]==T[i]:

        T[i]="o"



for i in T:

    c+=jan(i)



print(c)
N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))  # RSP グーチョキパー
T = list(eval(input()))
c = 0


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


for i in range(K, N):
    if T[i - K] == T[i]:
        T[i] = "o"
for i in range(1, K + 1):  # modK
    for j in range(N // K + 1):
        if i + K * j > N:
            continue
        c += jan(T[i + K * j - 1])
print(c)

N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))  # RSP グーチョキパー
T = list(eval(input()))
c = 0


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


for i in range(K, N):
    if T[i - K] == T[i]:
        T[i] = "o"
for i in T:
    c += jan(i)
print(c)

-for i in range(1, K + 1):  # modK -    for j in range(N // K + 1): -        if i + K * j > N: -            continue -        c += jan(T[i + K * j - 1]) +for i in T: +    c += jan(i)