let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let (n, k) = Scanf.sscanf (read_line ()) "%d %d" @@ fun n k -> (n, k)
let (r, s, p) = Scanf.sscanf (read_line ()) "%d %d %d" @@ fun r s p -> (r, s, p)
let t = read_line () |> split_string |> Array.of_list

let () =
  let res = Array.make n false in
  for i = 0 to n - 1 do
    if i < k then res.(i) <- true
    else if t.(i) <> t.(i - k) || not res.(i - k) then res.(i) <- true
  done;
  Printf.printf "%d\n" @@ Array.fold_left (+) 0 @@
    Array.mapi (fun i h -> 
      if res.(i) then match h with
        | "r" -> p
        | "s" -> r
        | _ -> s
      else 0
    ) t
