import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val k = sc.nextInt()
  val r = sc.nextLong()
  val s = sc.nextLong()
  val p = sc.nextLong()
  val t = sc.next()


  val array = CharArray(n)
  val score = LongArray(n)
  for ((i, ti) in t.withIndex()) {
    if (ti == 'r') {
      array[i] = 'p'
      score[i] = p
    }
    if (ti == 's') {
      array[i] = 'r'
      score[i] = r
    }
    if (ti == 'p') {
      array[i] = 's'
      score[i] = s
    }
  }

  // println(array.joinToString(""))
  // println(score.joinToString(""))

  for (i in k until n) {
    val pre = array[i-k]
    val now = array[i]


    if (pre == now) {
      var next = 'x'
      if (i+k < n) {
        next = array[i+k]
      }
      var tmp = 'x'
      if (now == 'r') {
        if (next == 'r') tmp = 'x'
        if (next == 's') tmp = 'p'
        if (next == 'p') tmp = 's'
      } else if (now == 's') {
        if (next == 'r') tmp = 'p'
        if (next == 's') tmp = 'x'
        if (next == 'p') tmp = 'r'
      } else if (now == 'p') {
        if (next == 'r') tmp = 's'
        if (next == 's') tmp = 'r'
        if (next == 'p') tmp = 'x'
      }
      
      array[i] = tmp
      score[i] = 0
    }
  }

  // println(array.joinToString(""))
  // println(score.joinToString(""))
  println(score.sum())


}
