n, k = gets.split.map(&:to_i)
s, p, r = gets.split.map(&:to_i)
scores = { s: s, p: p, r: r }
total = 0
t = gets.chop.chars

n.times do |i|
  if t[i] == t[i - k] && i - k >= 0
    t[i] = nil
    next
  end

  total += scores[t[i].to_sym]
end

p total
