object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N, K, R, S, P = in.nextInt
  val T = in.next

  case class Rsp(r: Int, s: Int, p: Int)

  def score(i: Int, pre: Rsp): Int = {
    val cur = curScore(i)
    val next = Rsp(
      math.max(pre.s + cur.r, pre.p + cur.r),
      math.max(pre.r + cur.s, pre.p + cur.s),
      math.max(pre.r + cur.p, pre.s + cur.p))
    (i + K) match {
      case j if j >= N => next.r max next.s max next.p
      case j => score(j, next)
    }
  }

  def curScore(i: Int): Rsp = T.charAt(i) match {
    case 'r' => Rsp(0, 0, P)
    case 's' => Rsp(R, 0, 0)
    case 'p' => Rsp(0, S, 0)
  }

  println((0 until K).map(i => score(i + K, curScore(i))).sum)
}