fun main(args: Array<String>) {
    val (N, K) = readIntList()
    val (R, S, P) = readIntList()
    val T = readString()
    var ans = 0
    for (k in 0 until K) {
        var pre = 'x'
        for (n in k until N step K) {
            val t = T[n]
            if (t == pre) {
                pre = 'x'
                continue
            }
            ans += when (t) {
                'r'  -> P
                'p'  -> S
                's'  -> R
                else -> 0
            }
            pre = t
        }
    }

    println(ans)
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)