# frozen_string_literal: true

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

c = Hash.new
c['r'] = p
c['s'] = r
c['p'] = s

d = Array.new(n) { false }
sum = 0

k.times do |i|
  sum += c[t[i]]
end
(k..(n - 1)).each do |i|
  if t[i] == t[i - k] && !d[i - k]
    d[i] = true
    next
  end

  sum += c[t[i]]
end

puts sum
