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

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

t=list(eval(input()))

hl=[]

ans=0

for i in range(n):

		if i<k:

			if t[i]=='r':

				ans+=p

				hl.append('r')

			elif t[i]=='p':

				ans+=s

				hl.append('p')

			elif t[i]=='s':

				ans+=r

				hl.append('s')

		elif i>=k:

			if t[i]==hl[i-k]:

				hl.append('a')

			else: 

				if t[i]==('r'):

					ans+=p

					hl.append('r')

				elif t[i]=='p':

					ans+=s

					hl.append('p')

				elif t[i]=='s':

					ans+=r

					hl.append('s')

print(ans)

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

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

t=list(eval(input()))

ans=0

for i in range(n):

    if i<k:

        if t[i]=="r":

            ans+=r

        elif t[i]=="s":

            ans+=s

        elif t[i]=="p":

            ans+=p

    else:

        if t[i]==t[i-k]:

            t[i]="a"

        else:

            if t[i]=="r":

                ans+=r

            elif t[i]=="s":

                ans+=s

            elif t[i]=="p":

                ans+=p

print(ans)
n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))
t = list(eval(input()))
hl = []
ans = 0
for i in range(n):
    if i < k:
        if t[i] == "r":
            ans += p
            hl.append("r")
        elif t[i] == "p":
            ans += s
            hl.append("p")
        elif t[i] == "s":
            ans += r
            hl.append("s")
    elif i >= k:
        if t[i] == hl[i - k]:
            hl.append("a")
        else:
            if t[i] == ("r"):
                ans += p
                hl.append("r")
            elif t[i] == "p":
                ans += s
                hl.append("p")
            elif t[i] == "s":
                ans += r
                hl.append("s")
print(ans)

n, k = list(map(int, input().split()))
s, p, r = list(map(int, input().split()))
t = list(eval(input()))
ans = 0
for i in range(n):
    if i < k:
        if t[i] == "r":
            ans += r
        elif t[i] == "s":
            ans += s
        elif t[i] == "p":
            ans += p
    else:
        if t[i] == t[i - k]:
            t[i] = "a"
        else:
            if t[i] == "r":
                ans += r
            elif t[i] == "s":
                ans += s
            elif t[i] == "p":
                ans += p
print(ans)

-r, s, p = list(map(int, input().split())) +s, p, r = list(map(int, input().split())) -hl = [] +            ans += r +        elif t[i] == "s": +            ans += s +        elif t[i] == "p": -            hl.append("r") -        elif t[i] == "p": -            ans += s -            hl.append("p") -        elif t[i] == "s": -            ans += r -            hl.append("s") -    elif i >= k: -        if t[i] == hl[i - k]: -            hl.append("a") +    else: +        if t[i] == t[i - k]: +            t[i] = "a" -            if t[i] == ("r"): +            if t[i] == "r": +                ans += r +            elif t[i] == "s": +                ans += s +            elif t[i] == "p": -                hl.append("r") -            elif t[i] == "p": -                ans += s -                hl.append("p") -            elif t[i] == "s": -                ans += r -                hl.append("s")