program ddd
implicit none

integer :: n, k, r, s, p, i, res
character(10**5) :: t

read*, n, k
read*, r, s, p
read*, t

res = 0

do i = 1, n
	if (t(i:i)=='r') res=res + p
    if (t(i:i)=='s') res=res + r
	if (t(i:i)=='p') res=res + s
end do

do i = k + 1, n
	if (t(i:i)==t(i-k:i-k)) then
    	if (t(i:i)=='r') then
        res = res - p
        t(i:i) = 'q'
    	else if (t(i:i)=='s') then
		res = res - r
        t(i:i) = 'q'
        else if (t(i:i)=='p') then
        res = res - s
        t(i:i) = 'q'
        end if
	end if
end do

print*, res

end program