'use strict'

function Main(input) {
  input = input.trim().split('\n')
  const a = input[0].split(' ').map(s => parseInt(s))
  const N = a[0]
  const K = a[1]
  const rest = input[1].split(' ').map(s => parseInt(s))
  const R = rest[0]
  const S = rest[1]
  const P = rest[2]
  const T = input[2]

  var total = 0
  
  var dp = Array(N)
  dp.fill(0)

  for(var i = 0; i < N; ++i){
    let ans = T[i]
    if (ans === 'r') {
      total += P
      dp[i] = 'p'
    } 

    if(ans === 's') {
      total += R
      dp[i] = 'r'
    }

    if(ans === 'p') {
      total += S
      dp[i] = 's'
    }    
  }

  for(var i = K; i < N; ++i) {
    let ans = T[i]
    let target = dp[i - K]
    if (ans === 'r' && target === 'p' ) {
      dp[i] = 'r'
      total -= P
    }

    if (ans === 's' && target === 'r') {
      dp[i] = 's'
      total -= R
    }

    if (ans === 'p' && target === 's') {
      dp[i] = 'p'
      total -= S
    }
  }

  console.log(total)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));