N, K = gets.chomp.split.map(&:to_i)

S = gets.chomp.split.map(&:to_i)

T = gets.chomp.chars

class String
  SCORE = %w[r s p].zip(S).to_h
  WIN   = { 'r' => 'p', 's' => 'r', 'p' => 's' }

  def score
    SCORE.fetch(self)
  end

  def win
    WIN.fetch(self)
  end
end

me = []
score = 0

0.upto(K - 1) do |i|
  me << T[i].win
  score += me[-1].score
end

K.upto(N - 1) do |i|
  if T[i].win != me[i - K]
    me << T[i].win
    score += me[-1].score
    next
  end

  if i + K < N
    choice = %w[r s p] - [me[i - K], T[i + K].win]
    me << choice.first
    next
  end

  me << T[i]
end

print score
