n, k = gets.chomp.split.map(&:to_i)
R, S, P = gets.chomp.split.map(&:to_i)
t = gets.chomp.split('')

def win(hand)
  case hand # 相手の
  when 'r'
    P
  when 's'
    R
  when 'p'
    S
  end
end

ans = 0
n.times do |i|
  if i <= k - 1
    ans += win(t[i])
  else
    if t[i] == t[i-k]
      t[i] = 'no'
    else
      ans += win(t[i])
    end
  end
end
p ans
