n, k = gets.split.map(&:to_i)
r, s, p = gets.split.map(&:to_i)
t_input = gets.split('').map(&:to_s)
t_output = Array.new(n-1)
(0..n-1).each do |i|
  case t_input[i]
  when 'r'
    t_output[i] = 'p'
  when 's'
    t_output[i] = 'r'
  else
    t_output[i] = 's'
  end
end
(k..n-1).each do |i|
  t_output[i] = 't' if t_output[i] == t_output[i-k]
end
r_score = r * t_output.count('r')
s_score = s * t_output.count('s')
p_score = p * t_output.count('p')
puts r_score + s_score + p_score
