n, k = gets.split.map(&:to_i)
r, s, p = gets.split.map(&:to_i)
t = gets.chomp
point = 0
for i in 0..n - 1
  if t[i - k] == t[i] && i >= k
    t[i] = 'n'
  end
  if t[i] == 'r'
    point += p
  elsif t[i] == 's'
    point += r
  elsif t[i] == 'p'
    point += s
  end
end
puts point
