from sys import stdin

from itertools import groupby

import math 



n,k = [int(x) for x in stdin.readline().rstrip().split()]

r,s,p = [int(x) for x in stdin.readline().rstrip().split()]

t = stdin.readline().rstrip()

t = [i for i in t]

point = 0



for i in range(k):

    li = t[i::k]

    lin = []

    for key, value in groupby(li):

        lin.append((key,len(list(value))))

    for j in lin:

        if j[0] == "r":

            point += math.ceil(j[1]/2)*p

        elif j[0] == "s":

            point += math.ceil(j[1]/2)*r

        else:

            point += math.ceil(j[1]/2)*s



print(point)
from itertools import groupby



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

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

t = list(eval(input()))



point = 0



for i in range(k):

    li = ["x"]+t[i::k]

    for j in range(1,len(li)):

        if li[j-1] == li[j]:

            li[j] = "x"

            continue

        if li[j] == "r":

            point += p

        elif li[j] == "s":

            point += r

        else:

            point += s

    

print(point)
from sys import stdin
from itertools import groupby
import math

n, k = [int(x) for x in stdin.readline().rstrip().split()]
r, s, p = [int(x) for x in stdin.readline().rstrip().split()]
t = stdin.readline().rstrip()
t = [i for i in t]
point = 0
for i in range(k):
    li = t[i::k]
    lin = []
    for key, value in groupby(li):
        lin.append((key, len(list(value))))
    for j in lin:
        if j[0] == "r":
            point += math.ceil(j[1] / 2) * p
        elif j[0] == "s":
            point += math.ceil(j[1] / 2) * r
        else:
            point += math.ceil(j[1] / 2) * s
print(point)

from itertools import groupby

n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = list(eval(input()))
point = 0
for i in range(k):
    li = ["x"] + t[i::k]
    for j in range(1, len(li)):
        if li[j - 1] == li[j]:
            li[j] = "x"
            continue
        if li[j] == "r":
            point += p
        elif li[j] == "s":
            point += r
        else:
            point += s
print(point)

-from sys import stdin -import math -n, k = [int(x) for x in stdin.readline().rstrip().split()] -r, s, p = [int(x) for x in stdin.readline().rstrip().split()] -t = stdin.readline().rstrip() -t = [i for i in t] +n, k = list(map(int, input().split())) +r, s, p = list(map(int, input().split())) +t = list(eval(input())) -    li = t[i::k] -    lin = [] -    for key, value in groupby(li): -        lin.append((key, len(list(value)))) -    for j in lin: -        if j[0] == "r": -            point += math.ceil(j[1] / 2) * p -        elif j[0] == "s": -            point += math.ceil(j[1] / 2) * r +    li = ["x"] + t[i::k] +    for j in range(1, len(li)): +        if li[j - 1] == li[j]: +            li[j] = "x" +            continue +        if li[j] == "r": +            point += p +        elif li[j] == "s": +            point += r -            point += math.ceil(j[1] / 2) * s +            point += s