n, k = gets.split.map(&:to_i)
r, s, p = gets.split.map(&:to_i)
t = gets.chomp

v = {}
v["r"] = p
v["s"] = r
v["p"] = s

sum = 0
prev = "."
for i in 0...k do
  j = i
  while j < n do
    if t[j] != prev
      sum += v[t[j]]
      prev = t[j]
    else
      prev = "."
    end
    j += k
  end
end
puts sum
