fun main(args: Array<String>) {
    val (N, K) = readLine()!!.split(" ").map(String::toInt)
    val (GUU, CHOKI, PAR) = readLine()!!.split(" ").map(String::toInt)
    val T = readLine()!!

    fun calc(c: Char): Int {
        return when (c) {
            'r' -> PAR
            's' -> GUU
            else -> CHOKI
        }

    }

    var scores = IntArray(T.length)
    for (i in T.indices) {
        scores[i] = if (i < K || (T[i] != T[i - K] || scores[i - K] == 0)) {
            calc(T[i])
        } else {
            0
        }
    }
    println(scores.sum())

}

