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

a = t.map.with_index.group_by {|v, i| i % k}

score = {"r" => p, "s" => r, "p" => s}

ans = 0
prev = ""
a.each do |k, aa|
  aa.each do |aaa|
    if prev != aaa[0]
      ans += score[aaa[0]]
      prev = aaa[0]
    else
      prev = ""
    end
  end
end
p ans