N,K=gets.split.map(&:to_i)
R,S,P=gets.split.map(&:to_i)
sc=Hash.new{0}
sc["r"]=P
sc["s"]=R
sc["p"]=S
T=gets.chomp
ans=0
take=false
K.times do |i|
  ((N+K-1-i)/K).times do |j|
    if j==0
      ans+=sc[T[i+K*j]]
      take=true
    else
      if T[i+K*j]!=T[i+K*(j-1)] || !take
        ans+=sc[T[i+K*j]]
        take=true
      else
        take=false
      end
    end
  end
end
puts ans