object Main extends App {
  val Array(n, k) = scala.io.StdIn.readLine.split(' ').map(_.toInt)
  val Array(r, s, p) = scala.io.StdIn.readLine.split(' ').map(_.toInt)
  val t = scala.io.StdIn.readLine

  var count = 0
  var memo = Array[Char]()
  t.zipWithIndex.foreach({ case (char, i) =>
    char match {
      case 'r' => {
        if (memo.lift(i - k).isEmpty || memo(i - k) != 'p') {
          count += p
          memo = memo :+ 'p'
        } else memo = memo :+ 'x'
      }
      case 's' => {
        if (memo.lift(i - k).isEmpty || memo(i - k) != 'r') {
          count += r
          memo = memo :+ 'r'
        } else memo = memo :+ 'x'
      }
      case 'p' => {
        if (memo.lift(i - k).isEmpty || memo(i - k) != 's') {
          count += s
          memo = memo :+ 's'
        }else {
          memo = memo :+ 'x'
        }
      }
    }
  })

  println(count)

}
