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' -> 2
            's' -> 0
            else -> 1
        }
    }.toIntArray()

    val grouped = t.withIndex().groupBy { it.index % k }
        .map { it.value.map { iv -> iv.value } }

    var answer = 0L

    for (g in grouped) {
        val before = Array(g.size) { -1 }
        before[0] = g.first()
        answer += points[g.first()]

        for (i in 1..g.lastIndex) {
            val value = g[i]
            if (before[i - 1] != value) {
                answer += points[value]
                before[i] = value
            }
        }
    }

    println(answer)
}
