fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val (R, S, P) = readLine()!!.split(" ").map { it.toLong() }
    val t = StringBuilder(readLine()!!)
    val m = mapOf('r' to P, 's' to R, 'p' to S, 'x' to 0L)

    (k until t.length).forEach {
        if (it < k) return@forEach
        if (t[it] == t[it - k]) t[it] = 'x'
    }

    println(t.map { m[it] ?: 0L }.sum())
}
