import java.io.*
import java.util.*

const val ROCK = 0
const val SCISSOR = 1
const val PAPER = 2
val HANDS = listOf(ROCK, SCISSOR, PAPER)
fun solve(N: Int, K: Int, R: Int, S: Int, P: Int, T: String) {
    fun score(index: Int, rsp: Int) = when {
        (T[index] == 'r' && rsp == PAPER) -> P
        (T[index] == 's' && rsp == ROCK) -> R
        (T[index] == 'p' && rsp == SCISSOR) -> S
        else -> 0
    }
    // Kで割ったあまりごとに配列を分ける -> それぞれの最大値のsumを求める
    fun maximum(remainder: Int): Int{
        // dp[i][j] = remainder + j * K回目にiを出して出せる最高得点
        // remainder + size * K <= N - 1
        val size = (N - remainder - 1) / K + 1
        val dp = Array(3) { IntArray(size) }
        for (hand in HANDS) dp[hand][0] = score(remainder, hand)
        for (i in 1 until size) {
            for (hand in HANDS) {
                dp[hand][i] = Math.max(
                        dp[(hand + 1) % 3][i-1] + score(remainder + i*K , hand),
                        dp[(hand + 2) % 3][i-1] + score(remainder + i *K, hand)
                    )
            }
        }
        // println(dp.contentDeepToString())
        return HANDS.map{ hand -> dp[hand].last() }.max()!!
    }
    val ans = (0..K-1).map{ maximum(it) }.sum()
    println(ans)
    return
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val K = sc.next().toInt()
    val R = sc.next().toInt()
    val S = sc.next().toInt()
    val P = sc.next().toInt()
    val T = sc.next()
    solve(N, K, R, S, P, T)
}
