# frozen_string_literal: true

_, k = gets.split.map(&:to_i)
r, s, p = gets.split.map(&:to_i)
h = { 'r' => p, 's' => r, 'p' => s }
t = gets.chomp
score = 0

t.chars.group_by.with_index { |_, index| index % k }.each_value do |i|
  pred = nil

  i.each do |j|
    if pred != j
      score += h[j]
      pred = j
    else
      pred = nil
    end
  end
end

puts score