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

res=0
rec=[]
t.each_with_index do |e,i|
  case e
  when "r"
    if rec.size < k
      rec << "p"
      res += p
    elsif rec.size >= k
      if rec[i-k] != "p"
        rec << "p"
        res += p
      else
        rec << "."
        res += 0
      end
    end
  when "s"
    if rec.size < k
      rec << "r"
      res += r
    elsif rec.size >= k
      if rec[i-k] != "r"
        rec << "r"
        res += r
      else
        rec << "."
        res += 0
      end
    end
  when "p"
    if rec.size < k
      rec << "s"
      res += s
    elsif rec.size >= k
      if rec[i-k] != "s"
        rec << "s"
        res += s
      else
        rec << "."
        res += 0
      end
    end
  end
end
puts res