let () =
    let main () =
        let n, k = Scanf.sscanf (read_line ()) "%d %d" (fun n k -> n, k) in
        let r, s, p = Scanf.sscanf (read_line ()) "%d %d %d" (fun r s p -> r, s, p) in
        let t = read_line () in
        let judge a b =
            match a, b with
            | 's', 'r' -> r
            | 'p', 's' -> s
            | 'r', 'p' -> p
            | _ -> 0
        in
        let z = "rsp" in
        let rec loop offset acc =
            let rec calc offset acc =
                if offset >= n then Array.fold_left max 0 acc else (
                    let newacc = [| 0; 0; 0 |] in
                    newacc.(0) <- max (acc.(1) + judge t.[offset] z.[0]) (acc.(2) + judge t.[offset] z.[0]);
                    newacc.(1) <- max (acc.(0) + judge t.[offset] z.[1]) (acc.(2) + judge t.[offset] z.[1]);
                    newacc.(2) <- max (acc.(0) + judge t.[offset] z.[2]) (acc.(1) + judge t.[offset] z.[2]);
                    calc (offset + k) newacc
                )
            in
            if offset = k then acc else loop (offset + 1) (acc + calc offset [| 0; 0; 0 |])
        in
        loop 0 0 |> Printf.printf "%d\n"
    in
    main ()