! 2019.12.29
!
      program answer
      implicit none
      integer :: N,K
      integer :: R,S,P
      character(len=100000) :: T
      integer :: i
      integer :: score,scJ
      integer :: ans
!
      read(*,*) N,K
      read(*,*) R,S,P
      read(*,*) T
!
      ans = 0
      do i=1,N
        if(T(i:i) == 'r') then
          score = P
        else if(T(i:i) == 's') then
          score = R
        else
          score = S
        end if
!
        scJ = 0
        if( i > K) then
          if( T(i:i) == T((i-K):(i-K))) then
            scJ=1
            T(i:i) = 'u'
          end if
        end if
        if(scJ == 0) then 
          ans = ans + score
        end if
      end do
      write(*,*) ans
      end program answer