program main
  implicit none
  integer(8) :: n, k, i, r, s, p, res
  character(100000) :: t, used
  character(1) :: using
  read (*, *) n, k
  read (*, *) r, s, p
  read (*, *) t
  res = 0
  do i = 1, n
    if (i <= k) then
      using = t(i:i)
    else
      if (t(i:i) == used(i - k:i - k)) then
        using = "*"
      else
        using = t(i:i)
      end if
    end if
    if (using == "r") then
      res = res + p
    else if (using == "p") then
      res = res + s
    else if (using == "s") then
      res = res + r
    end if
    used(i:i) = using
  end do
  write (*, "(i0)") res
end program main
