n, k = gets.chomp.split(' ').map(&:to_i)
arr = gets.chomp.split(' ').map(&:to_i)
rps_points = {}
["r", "s", "p"].each_with_index do |a, i|
  rps_points.merge!({"#{a}": arr[i]})
end
rps_points = rps_points.sort_by{|_, v| -v}
t = gets.chomp.split('')
t.each_with_index do |i, index|
  t[index] = 'r' if i=='s'
  t[index] = 's' if i=='p'
  t[index] = 'p' if i=='r'
end

points = Array.new(n, 0)
rps_points.each do |rps_point|  
  t.each_with_index do |i, index|
    if index-k>=0 && t[index-k]==i && points[index-k]!=0
      next
    elsif rps_point[0].to_s==i
      points[index] = rps_point[1]
    end
  end
end
print(points.reduce(:+))