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//.map{case (e, index) => (e, index + 1)}
  var meList = scala.collection.mutable.Seq[String]()
  
  youList.foreach {case (e, index) =>
    if (e == "r")
    	if (index >= k && meList(index - k) == "p") meList = meList :+ "X"
    	else meList = meList :+ "p"
    else if (e == "s")
    	if (index >= k && meList(index - k) == "r") meList = meList :+ "X"
    	else meList = meList :+ "r"
    else if (e == "p")
    	if (index >= k && meList(index - k) == "s") meList = meList :+ "X"
    	else meList = meList :+ "s"
  }  
  println(meList.map(e => 
    if (e == "r") r
    else if (e == "s") s
    else if (e == "p") p
    else 0
  ).sum)
}