n,k = gets.split.map(&:to_i)
R,S,P = gets.split.map(&:to_i)
t = gets.strip

win = {
  'r' => 'p',
  's' => 'r',
  'p' => 's',
}
points = {
  'r' => R,
  's' => S,
  'p' => P,
}

total = 0

pattern = t.chars
result = []

pattern.each.with_index do |rsp, i|
  if i+1 > k && pattern[i-k] == rsp && result[i-k]
    result[i] = false
    next
  end
  total += points[win[rsp]]
  result[i] = true
end

puts total
