n,k = gets.split(' ').map(&:to_i)
r,s,p = gets.split(' ').map(&:to_i)
t = gets.chomp.split('')
score = 0 
t_hand = []
(0..n-1).each do |i| 
  if t[i] == 'r' 
    t_hand << 'p' 
    score += p
  elsif t[i] == 's' 
    t_hand << 'r' 
    score += r
  elsif t[i] == 'p' 
    t_hand << 's' 
    score += s
  end 
end
temp = 's' 
(k..n-1).each do |i| 
  flag1 = 0 

  if t_hand[i] == t_hand[i-k]
    score -= r if t_hand[i] == 'r' 
    score -= s if t_hand[i] == 's' 
    score -= p if t_hand[i] == 'p' 
    flag1 = 1 
    temp = t_hand[i]
  end 
  if flag1 == 1
    t_hand[i] = 'p' if temp == 's' 
    t_hand[i] = 's' if temp == 'r' 
    t_hand[i] = 'r' if temp == 'p' 
    flag = 0 
    if t_hand[i] == t_hand[i+k]
      flag = 1 
      temp = t_hand[i]
    end 
    if flag == 1
      t_hand[i] = 'p' if temp == 's' 
      t_hand[i] = 's' if temp == 'r' 
      t_hand[i] = 'r' if temp == 'p'                                                                     
    end 
  end 
end
puts score