import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

    val n = sc.nextInt()
    val k = sc.nextInt()
    val r = sc.nextInt()
    val s = sc.nextInt()
    val p = sc.nextInt()

    val t = sc.next()

    var sum = 0
    for (i in 0 until k) {
        sum += solve(n, k, i, listOf(p, s, r), t)
    }
    println(sum)
}

val dp = Array(1e5.toInt()) { Array(3) { 0 } }

fun solve(n: Int, k: Int, i: Int, sc: List<Int>, t: String): Int {


    val a = "rps"

    dp[i][a.indexOf(t[i])] = sc[a.indexOf(t[i])]

    var last = i
    for (j in i + k until n step k) {
        last = j
        for (q in 0..2) {
            var best = -1
            for (prev in 0..2) {
                if (q == prev) continue
                if (best < dp[j - k][prev]) best = dp[j - k][prev]
            }

            if (a.indexOf(t[j]) == q) best += sc[q]
            dp[j][q] = best
        }
    }

    var ans = -1
    for (q in 0..2) {
        if (ans < dp[last][q]) ans = dp[last][q]
    }
    return ans
}


class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}
