object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  val ls0 = in(0).split(' ').map(_.toInt)
  val ls1 = in(1).split(' ').map(_.toInt)
  val T = in(2)//.split(' ').map(_.toInt)
  val K = ls0(1)
  val R = ls1(0)
  val S = ls1(1)
  val P = ls1(2)
  val N = T.size
  
  val t = (0 until N).map(_ => ' ').toArray
  
  var sum = 0
  (0 until N).foreach{ i =>
    val pt = T(i) match {
      case 'r' => P
      case 's' => R
      case 'p' => S
    }
    //println(pt, sum)
    if( i-K < 0 || (0 <= (i-K) && t(i-K) != T(i))){
      sum += pt
      t(i) = T(i)
    }
    //sum += pt
  }
  println(sum)
}

