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

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

t=list(eval(input()))



point=dict()

point["p"]=s  #s wins p

point["s"]=r  #r wins s

point["r"]=p  #p wins r

point["checked"]=0



ans=0

for i in range(n):

  tmp=i-k

  if tmp>=0 and t[tmp]==t[i]:

    ans+=0

    t[i]="checked"

  else:

    ans+=point[t[i]]

print(ans)

def main():



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

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

  t=list(eval(input()))



  point=dict()

  point["p"]=s  #s wins p

  point["s"]=r  #r wins s

  point["r"]=p  #p wins r

  point["checked"]=0



  ans=0

  for i in range(n):

    tmp=i-k

    if tmp>=0 and t[tmp]==t[i]:

      ans+=0

      t[i]="checked"

    else:

      ans+=point[t[i]]

  print(ans)



main()
n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = list(eval(input()))
point = dict()
point["p"] = s  # s wins p
point["s"] = r  # r wins s
point["r"] = p  # p wins r
point["checked"] = 0
ans = 0
for i in range(n):
    tmp = i - k
    if tmp >= 0 and t[tmp] == t[i]:
        ans += 0
        t[i] = "checked"
    else:
        ans += point[t[i]]
print(ans)

def main():
    n, k = list(map(int, input().split()))
    r, s, p = list(map(int, input().split()))
    t = list(eval(input()))
    point = dict()
    point["p"] = s  # s wins p
    point["s"] = r  # r wins s
    point["r"] = p  # p wins r
    point["checked"] = 0
    ans = 0
    for i in range(n):
        tmp = i - k
        if tmp >= 0 and t[tmp] == t[i]:
            ans += 0
            t[i] = "checked"
        else:
            ans += point[t[i]]
    print(ans)


main()

-n, k = list(map(int, input().split())) -r, s, p = list(map(int, input().split())) -t = list(eval(input())) -point = dict() -point["p"] = s  # s wins p -point["s"] = r  # r wins s -point["r"] = p  # p wins r -point["checked"] = 0 -ans = 0 -for i in range(n): -    tmp = i - k -    if tmp >= 0 and t[tmp] == t[i]: -        ans += 0 -        t[i] = "checked" -    else: -        ans += point[t[i]] -print(ans) +def main(): +    n, k = list(map(int, input().split())) +    r, s, p = list(map(int, input().split())) +    t = list(eval(input())) +    point = dict() +    point["p"] = s  # s wins p +    point["s"] = r  # r wins s +    point["r"] = p  # p wins r +    point["checked"] = 0 +    ans = 0 +    for i in range(n): +        tmp = i - k +        if tmp >= 0 and t[tmp] == t[i]: +            ans += 0 +            t[i] = "checked" +        else: +            ans += point[t[i]] +    print(ans) + + +main()