let n, k, r, s, p = Scanf.scanf " %d %d %d %d %d" @@ fun a b c d e -> a, b, c, d, e
let f = function 'r' -> 'p' | 's' -> 'r' | _ -> 's'
let ws = Array.init n @@ fun _ -> Scanf.scanf " %c" f
let ans = ref 0
let g t u = List.(filter (fun x -> x <> t && x <> u) ['r'; 's'; 'p'] |> hd)
let h = function 'r' -> r | 's' -> s | _ -> p
let _ = Array.iteri (fun i w -> if i - k >= 0 && ws.(i - k) = w then ws.(i) <- g w @@ if i + k < n then ws.(i + k) else w else ans := !ans + h w) ws; Printf.printf "%d\n" !ans