n,k = gets.split.map(&:to_i)
pt = gets.split.map(&:to_i)
t = gets.chomp #s=>0, p=>1, r=>2

ans = [0]*n
n.times do |i|
  m = t[i] == "s" ? 0 : (t[i] == "p" ? 1 : 2)
  if i >= k && t[i-k] == t[i] && ans[i-k] > 0
    #nothing
  else
    ans[i] = pt[m]
  end
end
p ans.inject(:+)