N, K =gets.split.map(&:to_i)
rock_get, scissors_get, paper_get = gets.split.map(&:to_i)
answers = gets.chomp

choice = []
score = 0
# 勝ち続けるのが基本?
# K回制限があるので


(0..(K-1)).each do |i|
  case answers[i]
  when 'r'
    choice << 'p'
    score += paper_get
  when 's'
    choice << 'r'
    score += rock_get
  when 'p'
    choice << 's'
    score += scissors_get
  end
end

(K..(N-1)).each do |i|
  case answers[i]
  when 'r'
    if choice[i - K] != 'p'
      choice << 'p'
      score += paper_get
    elsif answers[i + K] == 's'
      choice << 's'
    elsif answers[i + K] == 'p'
      choice << 'r'
    else
      choice << 'r'
    end
  when 's'
    if choice[i - K] != 'r'
      choice << 'r'
      score += rock_get
    elsif answers[i + K] == 'p'
      choice << 'p'
    elsif answers[i + K] == 'r'
      choice << 's'
    else
      choice << 's'
    end
  when 'p'
    if choice[i - K] != 's'
      choice << 's'
      score += scissors_get
    elsif answers[i + K] == 'r'
      choice << 'r'
    elsif answers[i + K] == 's'
      choice << 'p'
    else
      choice << 'p'
    end
  end
end

puts score
