n,k=gets.split.map(&:to_i)
r,s,p=gets.split.map(&:to_i)
t=gets.chomp.split("")
words = []
t.each do |word|
  case word
    when "r"; words << ["p",p]
    when "s"; words << ["r",r]
    when "p"; words << ["s",s]
  end
end
(n-k).times do |index|
  next_value = words[index+k][0]
  if words[index][0] == next_value
    array = ["r","s","p"]
    array.delete(next_value)
    next_value = array[0]
    if index+2*k < n
    	next_value = array[1] if next_value == words[index+2*k][0]
    end
    words[index+k] = [next_value,0]
  end 
end
puts words.map{|pattern,value|value}.inject(:+)