N, K = gets.chomp.split(" ").map(&:to_i)
R, S, P = gets.chomp.split(" ").map(&:to_i)
T = gets.chomp

def choice(i, t, v, win, lose, even)
  ret = 0
  if i >= K && t[-K] == win then
    if i + K < N && T[i + K] == win.downcase then
      t.concat(even)
    else
      t.concat(lose)
    end
  else
    ret = v
    t.concat(win)
  end
  ret
end

ans = 0
t = ""
N.times{|i|
  case T[i]
  when 'r' then
    ans += choice(i, t, P, 'P', 'S', 'R')
  when 's' then
    ans += choice(i, t, R, 'R', 'P', 'S')
  when 'p' then
    ans += choice(i, t, P, 'S', 'R', 'P')
  end
}

puts ans
