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

dp = Array.new(n, 0)

def point(c)
  case c
  when 'r'
    P
  when 's'
    R
  when 'p'
    S
  end
end

n.times do |i|
  if i < k - 1 || t[i-k] != t[i]
    dp[i] = point(t[i])
  else
    if dp[i-k] < point(t[i])
      dp[i-k] = 0
      dp[i] = point(t[i])
    else
      dp[i] = 0
    end
  end
end

# p dp
puts dp.inject(:+)