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

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

t = eval(input())

lis = ['' for _ in range(len(t))]

ans = 0



for i in range(k):

  if t[i] == 'r':

    ans += p

    lis[i] = 'p'

  elif t[i] == 'p':

    ans += s

    lis[i] = 's'

  else:

    ans += r

    lis[i] ='r'

    

for j in range(k,len(t)):

  if t[j] == 'p' and lis[j-k] != 's':

    ans+=s

    lis[j] = 's'

  elif t[j] == 'p' and lis[j-k] == 's':

    lis[j] = 'katenai'



    

  elif t[j] == 's' and lis[j-k] != 'r':

    ans+=r

    lis[j] = 'r'



  elif t[j] == 's' and lis[j-k] == 'r':

    lis[j] = 'katenai'



    

  elif t[j] == 'r' and lis[j-k] != 'p':

    ans+=p

    lis[j] = 'p'



  elif t[j] == 'r' and lis[j-k] == 'p':

    lis[j] = 'katenai'

      



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

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

T = eval(input())

 

flags = [0] * len(T)

 

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

 

point_sum = 0

 

for i, t in enumerate(T):

    if i < K:

        point_sum += point_map[t]

        continue

    if t == T[i-K] and not flags[i-K]:

        flags[i] = 1#勝ちを0，勝てなかったことをを1で表現している

        continue

    point_sum += point_map[t]



print(point_sum)
n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = eval(input())
lis = ["" for _ in range(len(t))]
ans = 0
for i in range(k):
    if t[i] == "r":
        ans += p
        lis[i] = "p"
    elif t[i] == "p":
        ans += s
        lis[i] = "s"
    else:
        ans += r
        lis[i] = "r"
for j in range(k, len(t)):
    if t[j] == "p" and lis[j - k] != "s":
        ans += s
        lis[j] = "s"
    elif t[j] == "p" and lis[j - k] == "s":
        lis[j] = "katenai"
    elif t[j] == "s" and lis[j - k] != "r":
        ans += r
        lis[j] = "r"
    elif t[j] == "s" and lis[j - k] == "r":
        lis[j] = "katenai"
    elif t[j] == "r" and lis[j - k] != "p":
        ans += p
        lis[j] = "p"
    elif t[j] == "r" and lis[j - k] == "p":
        lis[j] = "katenai"
print(ans)

N, K = list(map(int, input().split(" ")))
R, S, P = list(map(int, input().split(" ")))
T = eval(input())
flags = [0] * len(T)
point_map = {"r": P, "s": R, "p": S}
point_sum = 0
for i, t in enumerate(T):
    if i < K:
        point_sum += point_map[t]
        continue
    if t == T[i - K] and not flags[i - K]:
        flags[i] = 1  # 勝ちを0，勝てなかったことをを1で表現している
        continue
    point_sum += point_map[t]
print(point_sum)

-n, k = list(map(int, input().split())) -r, s, p = list(map(int, input().split())) -t = eval(input()) -lis = ["" for _ in range(len(t))] -ans = 0 -for i in range(k): -    if t[i] == "r": -        ans += p -        lis[i] = "p" -    elif t[i] == "p": -        ans += s -        lis[i] = "s" -    else: -        ans += r -        lis[i] = "r" -for j in range(k, len(t)): -    if t[j] == "p" and lis[j - k] != "s": -        ans += s -        lis[j] = "s" -    elif t[j] == "p" and lis[j - k] == "s": -        lis[j] = "katenai" -    elif t[j] == "s" and lis[j - k] != "r": -        ans += r -        lis[j] = "r" -    elif t[j] == "s" and lis[j - k] == "r": -        lis[j] = "katenai" -    elif t[j] == "r" and lis[j - k] != "p": -        ans += p -        lis[j] = "p" -    elif t[j] == "r" and lis[j - k] == "p": -        lis[j] = "katenai" -print(ans) +N, K = list(map(int, input().split(" "))) +R, S, P = list(map(int, input().split(" "))) +T = eval(input()) +flags = [0] * len(T) +point_map = {"r": P, "s": R, "p": S} +point_sum = 0 +for i, t in enumerate(T): +    if i < K: +        point_sum += point_map[t] +        continue +    if t == T[i - K] and not flags[i - K]: +        flags[i] = 1  # 勝ちを0，勝てなかったことをを1で表現している +        continue +    point_sum += point_map[t] +print(point_sum)