fun main(args: Array<String>) {
    abc149d()
}

fun abc149d() {
    val (n, k) = readLine()!!.split(' ').map { it.toInt() }
    val points = readLine()!!.split(' ').map { it.toInt() }
    val t = readLine()!!.map {
        when (it) {
            'r' -> 0
            's' -> 1
            else -> 2
        }
    }.toIntArray()

    fun cap3(value: Int): Int {
        return if (value >= 3) value % 3 else value
    }

    val chosen = IntArray(n) { -1 }
    var answer = 0L

    for (i in 0 until n) {
        val c = t[i]
        val win = cap3(c + 2)
        val list = if (i + 1 <= k) listOf(0, 1, 2) else listOf(0, 1, 2).filterNot { it == chosen[i - k] }
        val choose = if (win in list) win else -1
        chosen[i] = choose

        answer += if (choose == win) points[choose] else 0
    }

    println(answer)
}
