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
    logical,allocatable:: w(:)


    read*, n,k
    read*, r,s,p
    allocate(character(n):: t)
    allocate(w(n))
    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
    w(1:k) = .true.
    w(k+1:) = .false.

    do i=k+1,n
        if (t(i:i) == t(i-k:i-k) .and. w(i-k)) cycle
        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
        w(i) = .true.
    end do

    print'(i0)', ans

end program main