n, k = gets.chomp.split().map(&:to_i)
r, s, p = gets.chomp.split().map(&:to_i)
predicts = gets.chomp.chars
score = 0
wins = {r: p, s: r, p: s}
memo = Array.new(n, true)

n.times do |i|
  now = predicts[i]
  
  if i > k && predicts[ i - k ] === now && memo[i - k]
    #相手がk回前と同じ手を出した時は負ける、奇数回目なら勝てる
    memo[i] = false
    next
  end
  score += wins[now.to_sym]
end

puts score