program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,k
    integer(int32):: r,s,p
    integer(int32):: i,j,ans
    character(:),allocatable:: t
    character(1):: old


    read*, n,k
    read*, r,s,p
    allocate(character(n):: t)
    read*, t
    ans=0
    old=t(1:1)
    do i=1,k
        if (t(i:i) == 'r') then
            ans=ans+p
        else if (t(i:i) == 's') then
            ans=ans+r
        else
            ans=ans+s
        end if
    end do
    do i=1,k
        j=1
        do while (k*j+i <= n)
            if (t(k*j+i:k*j+i) /= old) then
                if (t(k*j+i:k*j+i) == 'r') then
                    ans=ans+p
                    old='r'
                else if (t(k*j+i:k*j+i) == 's') then
                    ans=ans+r
                    old='s'
                else
                    ans=ans+s
                    old='p'
                end if
            else
                old='a'
            end if
            j=j+1
        end do
    end do
    print'(i0)', ans

end program main