fun main(args : Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val (r, s, p) = readLine()!!.split(" ").map { it.toInt() }
    val tt = readLine()!!.toMutableList()

    var score = 0L

    tt.forEachIndexed { idx, it ->
        val addedScore = when (it) {
            'r' -> p
            's' -> r
            'p' -> s
            else -> 0
        }
        score += addedScore

        if (idx < k) return@forEachIndexed
        if (tt[idx-k] != it) return@forEachIndexed

        score -= addedScore
        tt[idx] = '-'
    }

    println(score)
}
