import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, K = in.next().toInt
  val R, S, P = in.next().toInt
  val T = in.next().toArray

  //
  val hash = Map(
    'r' -> P,
    's' -> R,
    'p' -> S
  )

  var ans = 0L
  for (k <- 0 until K) {
    var i = k
    var pre = '1'
    while (i < N) {
      val c = T(i)
      if(pre == c) {
        pre = '1'
      }
      else {
        ans += hash(c)
        pre = c
      }

      i += K
    }
  }

  println(ans)
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.toList))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
