#!/usr/bin/ruby

N, K = gets.chomp.split(" ").map(&:to_i)
R, S, P  = gets.chomp.split(" ").map(&:to_i)
T  = gets.chomp.split("")

k = []
total = 0
T.each_with_index{|t, i|
  n = ''
  #puts "k = #{k.join("")}"
  if k.size == K
     n = k.shift(1)[0]
  end
  if t == 'r'
     # p
     if n == 'p'
       if i + K < T.size
          k << T[i+K]
       else
          k << 'r'
       end
     else
       total += P
       k << 'p'
     end
  elsif t == 's'
     # r
     if n == 'r'
       if i + K < T.size
          k << T[i+K]
       else
          k << 's'
       end
     else
       total += R
       k << 'r'
     end
  elsif t == 'p'
     # s
     if n == 's'
       if i + K < T.size
          k << T[i+K]
       else
          k << 'p'
       end
     else
       total += S
       k << 's'
     end
  end

}


puts total
