n,k=gets.chomp.split(" ").map(&:to_i);
r,s,p=gets.chomp.split(" ").map(&:to_i);
t = gets.chomp
t = t.split('')
array = []
total = 0
l = k
i = 0
t.each do |char|
  if char == 's'
  	a = 'r'
  	total = total + r
  elsif char == 'p'
  	a = 's'
  	total = total + s
  else
  	a = 'p'
  	total = total + p
  end
  if k > 0
  	k = k - 1
  else
  	if a == array[i - l]
  	  if a == 'r'
  	  	total = total - r
  	  elsif a == 's'
  	  	total = total - s
  	  else
  	  	total = total - p
  	  end
  	  a = ''
  	end
  end
  array << a
  i = i + 1
end

print("#{total}\n")