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

W = {"r" => P, "s" => R, "p" => S}
dp = Array.new(N, 1)

ans = N.times.inject(0) do |s, i|
  dp[i] = dp[i - K] + 1 if i >= K && T[i] == T[i - K]
  dp[i].odd? ? s + W[T[i]] : s
end
puts ans