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

groups = t.each_with_index.group_by{|it, i| i % k}.values.map{|it| it.map{|a, i| a}}

point_of_win = {
    'r' => p,
    's' => r,
    'p' => s,
}
score = 0
groups.each{|g|
    skip = false
    (0..(g.size() - 1)).each{|i|
        if i == 0 || skip || g[i] != g[i - 1]
            skip = false
            score += point_of_win[g[i]]
        else
            skip = true
        end
    }
}

puts score
