N, K = gets.split.map!(&:to_i)
R, S, P = gets.split.map!(&:to_i)
T = gets.chomp.codepoints
GU = 114 # r
CHOKI = 115 # s
PA = 112 # p

def katite(t)
  if t == GU
    PA
  elsif t == CHOKI
    GU
  else
    CHOKI
  end
end

ans = 0
result = []
T.each_with_index do |t, i|
  k = katite(t)
  if i < K || k != result[i - K]
    result[i] = k
    ans += if k == GU
      R
    elsif k == CHOKI
      S
    else
      P
    end
  else
    cadets = [GU, CHOKI, PA]
    cadets -= [katite(i+K)] if i + K < N
    cadets -= [result[i - K]] if i >= K
    result[i] = cadets[0]
  end
end

puts ans