import 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
  val map = Map('r' -> 'p', 's' -> 'r', 'p' -> 's')
  val point = Map('r' -> r, 's' -> s, 'p' -> p)
  val l = t.zipWithIndex.groupBy(_._2 % k).map(_._2.unzip._1)
  val res = l
    .map(r => {
      r.foldLeft((0, 'x'))((a, b) => {
          map(b) match {
            case win if win == a._2 => (a._1, b)
            case win                => (a._1 + point(win), win)
          }
        })
        ._1
    })
    .sum
  println(res)
}
