import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val N = sc.nextInt
    val K = sc.nextInt
    val R = sc.nextInt
    val S = sc.nextInt
    val P = sc.nextInt
    val T = sc.next

    var result = 0
    for (k <- 0 until K) {
      val tb = new ArrayBuffer[Char]();
      var i = k
      while (i < T.length) {
        tb.append(T(i))
        i += K
      }

      println(tb.mkString(""))
      var a = 0
      var prev = '.'
      for (t <- tb) {
        val next = if (t == 'r') 'p' else if (t == 's') 'r' else if (t == 'p') 's' else '.'
        if (prev != next) {
          a = a + (if (t == 'r') P else if (t == 's') R else if (t == 'p') S else 0)
          prev = next
        } else {
          prev = '.'
        }
      }
      println(a)

      result += a
    }
    result.toString
  }
}
