import scala.io.StdIn._

object Main extends App {
  val Array(n,k) = readLine().split(" ").map(_.toInt)
  val Array(r,s,p) = readLine().split(" ").map(_.toInt)
  val T = readLine().split("")

  def solve() = {
    val scoreMap = Map("r" -> r, "s" -> s, "p" -> p)
    val myHands = Array.fill(n)("")
    T.zipWithIndex.foldLeft(0) { case (acc, (t, i)) =>
      if(i < k) {
        myHands(i) = winHandMap(t)
        acc + scoreMap(winHandMap(t))
      }
      else {
        if(myHands(i-k) != winHandMap(t)) {
          myHands(i) = winHandMap(t)
          acc + scoreMap(winHandMap(t))
        } else {
          myHands(i) = if(i+k < n) nonWinHand(t, Some(T(i+k))) else nonWinHand(t)
          acc
        }
      }
    }
  }

  def winHandMap(machineHand: String): String = {
    val winHand = Map("r" -> "p", "s" -> "r", "p" -> "s")
    winHand(machineHand)
  }

  def nonWinHand(machineHand: String, machineNextHand: Option[String] = None): String = {
    val hands = Seq("r", "s", "p")
    if(machineNextHand.isEmpty) machineHand
    else hands.diff(Seq(winHandMap(machineHand), winHandMap(machineNextHand.get))).head
  }

  println(solve())

}

