n, k = gets.split.map(&:to_i)
r, s, p = gets.split.map(&:to_i)
t = gets.chomp

res = Array.new(n, 0)
ans = 0
points = { r: p, s: r, p: s }
(0..n-1).each do |i|
  if i-k >= 0 && t[i] == t[i-k] && res[i-k] == 1
  else
    ans += points[t[i].to_sym]
    res[i] = 1
  end
end
puts ans