object Main extends App {
  val Array(n,k) = readLine.split(" ").map(_.toInt)
  val Array(r,s,p) = readLine.split(" ").map(_.toInt)
  val youList = readLine.split("").filter(_.nonEmpty).zipWithIndex
  var meList = scala.collection.mutable.Seq[Int]()
  
  youList.foreach {case (e, index) =>
    if (e == "r")
    	if (index >= k && meList(index - k) == p) meList = meList :+ 0
    	else meList = meList :+ p
    else if (e == "s")
    	if (index >= k && meList(index - k) == r) meList = meList :+ 0
    	else meList = meList :+ r
    else if (e == "p")
    	if (index >= k && meList(index - k) == s) meList = meList :+ 0
    	else meList = meList :+ s
  }  
  println(meList.sum)
}