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

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

T = eval(input())

dic = {'s':S,'p':P,'r':R}

def solve(T):

    ans = 0

    for i in range(K):

        ans += dic[T[i]]

        serial = 1

        for j in range(i+K,N,K):

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

                serial += 1

            else:

                serial = 1

            if serial%2==1:

                ans += dic[T[j]]

    return ans

print((solve(T)))



def solve():

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

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

  dic = {'r':P,'s':R,'p':S}

  T = eval(input())

  point = [0]*N

  for i in range(N):

    if i<K:

      point[i] = dic[T[i]]

    else:

      if T[i]!=T[i-K] or point[i-K]==0:

        point[i]=dic[T[i]]

  ans = sum(point)

  return ans

print((solve()))
N, K = list(map(int, input().split()))
S, P, R = list(map(int, input().split()))
T = eval(input())
dic = {"s": S, "p": P, "r": R}


def solve(T):
    ans = 0
    for i in range(K):
        ans += dic[T[i]]
        serial = 1
        for j in range(i + K, N, K):
            if T[j] == T[j - K]:
                serial += 1
            else:
                serial = 1
            if serial % 2 == 1:
                ans += dic[T[j]]
    return ans


print((solve(T)))

def solve():
    N, K = list(map(int, input().split()))
    R, S, P = list(map(int, input().split()))
    dic = {"r": P, "s": R, "p": S}
    T = eval(input())
    point = [0] * N
    for i in range(N):
        if i < K:
            point[i] = dic[T[i]]
        else:
            if T[i] != T[i - K] or point[i - K] == 0:
                point[i] = dic[T[i]]
    ans = sum(point)
    return ans


print((solve()))

-N, K = list(map(int, input().split())) -S, P, R = list(map(int, input().split())) -T = eval(input()) -dic = {"s": S, "p": P, "r": R} - - -def solve(T): -    ans = 0 -    for i in range(K): -        ans += dic[T[i]] -        serial = 1 -        for j in range(i + K, N, K): -            if T[j] == T[j - K]: -                serial += 1 -            else: -                serial = 1 -            if serial % 2 == 1: -                ans += dic[T[j]] +def solve(): +    N, K = list(map(int, input().split())) +    R, S, P = list(map(int, input().split())) +    dic = {"r": P, "s": R, "p": S} +    T = eval(input()) +    point = [0] * N +    for i in range(N): +        if i < K: +            point[i] = dic[T[i]] +        else: +            if T[i] != T[i - K] or point[i - K] == 0: +                point[i] = dic[T[i]] +    ans = sum(point) -print((solve(T))) +print((solve()))