n, k = gets.split.map &:to_i
ptR, ptS, ptP = gets.split.map &:to_i
enemy = gets.chomp.chars

hands = []
ans = 0

for i in 0 .. n - 1

  case enemy[i]

  when "r"
    if i < k
      hands << "p"
      ans += ptP
    else
      if hands[i - k] != "p"
        hands << "p"
        ans += ptP
      else
        hands << "n"
      end
    end

  when "s"
    if i < k
      hands << "r"
      ans += ptR
    else
      if hands[i - k] != "r"
        hands << "r"
        ans += ptR
      else
        hands << "n"
      end
    end

  when "p"
    if i < k
      hands << "s"
      ans += ptS
    else
      if hands[i - k] != "s"
        hands << "s"
        ans += ptS
      else
        hands << "n"
      end
    end
  end
end

puts ans
