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

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

T=input().replace("s","R").replace("p","S").replace("r","P")



ans=0



def win(type):

  if type=="R":

    return R

  elif type=="S":

    return S

  elif type=="P":

    return P

  return 0



yaku=set(["R","S","P"])

def rest(a,b):

  re=yaku-set([a,b])

  for c in re:

    return c



def restRand(a):

  re=yaku-set([a])

  for c in re:

    return c



me=[""]*len(T)

for i in range(len(T)):

  if i-K<0:

    ans+=win(T[i])

    me[i]=T[i]

  else:

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

      # 勝つ手は出せない

      # 残り二つのうち、K回あとに勝負がある場合、K回あとに勝てる手以外を出す

      if i+K<len(T):

        me[i]=rest(T[i],T[i+K])

      else:

        me[i]=restRand(T[i])

    else:

      # 勝つ手を出せる

      ans+=win(T[i])

      me[i]=T[i]



print(ans)

import sys

readline = sys.stdin.readline



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

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

T = list(readline().rstrip())



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

ans = 0

for i in range(len(T)):

  if i < K:

    ans += P[T[i]]

    continue

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

    T[i] = "x"

  else:

    ans += P[T[i]]

print(ans)
N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = input().replace("s", "R").replace("p", "S").replace("r", "P")
ans = 0


def win(type):
    if type == "R":
        return R
    elif type == "S":
        return S
    elif type == "P":
        return P
    return 0


yaku = set(["R", "S", "P"])


def rest(a, b):
    re = yaku - set([a, b])
    for c in re:
        return c


def restRand(a):
    re = yaku - set([a])
    for c in re:
        return c


me = [""] * len(T)
for i in range(len(T)):
    if i - K < 0:
        ans += win(T[i])
        me[i] = T[i]
    else:
        if me[i - K] == T[i]:
            # 勝つ手は出せない
            # 残り二つのうち、K回あとに勝負がある場合、K回あとに勝てる手以外を出す
            if i + K < len(T):
                me[i] = rest(T[i], T[i + K])
            else:
                me[i] = restRand(T[i])
        else:
            # 勝つ手を出せる
            ans += win(T[i])
            me[i] = T[i]
print(ans)

import sys

readline = sys.stdin.readline
N, K = list(map(int, readline().split()))
R, S, P = list(map(int, readline().split()))
T = list(readline().rstrip())
P = {"r": P, "s": R, "p": S}
ans = 0
for i in range(len(T)):
    if i < K:
        ans += P[T[i]]
        continue
    if T[i] == T[i - K]:
        T[i] = "x"
    else:
        ans += P[T[i]]
print(ans)

-N, K = list(map(int, input().split())) -R, S, P = list(map(int, input().split())) -T = input().replace("s", "R").replace("p", "S").replace("r", "P") +import sys + +readline = sys.stdin.readline +N, K = list(map(int, readline().split())) +R, S, P = list(map(int, readline().split())) +T = list(readline().rstrip()) +P = {"r": P, "s": R, "p": S} - - -def win(type): -    if type == "R": -        return R -    elif type == "S": -        return S -    elif type == "P": -        return P -    return 0 - - -yaku = set(["R", "S", "P"]) - - -def rest(a, b): -    re = yaku - set([a, b]) -    for c in re: -        return c - - -def restRand(a): -    re = yaku - set([a]) -    for c in re: -        return c - - -me = [""] * len(T) -    if i - K < 0: -        ans += win(T[i]) -        me[i] = T[i] +    if i < K: +        ans += P[T[i]] +        continue +    if T[i] == T[i - K]: +        T[i] = "x" -        if me[i - K] == T[i]: -            # 勝つ手は出せない -            # 残り二つのうち、K回あとに勝負がある場合、K回あとに勝てる手以外を出す -            if i + K < len(T): -                me[i] = rest(T[i], T[i + K]) -            else: -                me[i] = restRand(T[i]) -        else: -            # 勝つ手を出せる -            ans += win(T[i]) -            me[i] = T[i] +        ans += P[T[i]]