n,k = gets.split(' ').map(&:to_i)
r,s,p = gets.split(' ').map(&:to_i)
line = gets
#puts line
sum =0
#line.gsub!(/r/,'tama')
#puts line

 j = Array.new(k,0)
 #puts k
wari = n/k
#puts wari

for i in 0..k-1
  if line[i]=="r"
    sum+=p
  elsif line[i] == "s"
    sum+=r
  elsif line[i] == "p"
    sum+=s
  end
  #puts "syoki"
  #puts sum
end

if wari > 1
 for i in 1..wari-1
   for u in 0..k-1
     if line[i*k+u]==line[i*k+u-k] && j[u] == 1
       if line[i*k+u]=="r"
         sum+=p
       elsif line[i*k+u] == "s"
         sum+=r
       elsif line[i*k+u] == "p"
         sum+=s
       end
       j[u] = 0
   elsif line[i*k+u]==line[i*k+u-k] && j[u] == 0
     j[u] = 1
   else
     if line[i*k+u]=="r"
       sum+=p
     elsif line[i*k+u] == "s"
       sum+=r
     elsif line[i*k+u] == "p"
       sum+=s
     end
     j[u] = 0
   end
   #puts "middle"

   #puts sum
 end
end
end


t = 0
if wari>0
  for i in wari*k..n-1

    if line[i] == line[i-k] && j[t] == 1
      if line[i]=="r"
        sum+=p
      elsif line[i] == "s"
        sum+=r
      elsif line[i] == "p"
        sum+=s
      end
    elsif line[i] == line[i-k] && j[t] == 0
      sum+=0
    else
      if line[i]=="r"
        sum+=p
      elsif line[i] == "s"
        sum+=r
      elsif line[i] == "p"
        sum+=s
      end
    end
    t+=1
  end

  #puts "last"
  #puts sum
end


puts sum
