let [|N;K|] = stdin.ReadLine().Split() |> Array.map int
let [|R;S;P|] = stdin.ReadLine().Split() |> Array.map int
let T = stdin.ReadLine()

let f x y = if (x + y * K) < N then T.[x + y * K] else 'x'
let t = Array2D.init K ((N / K) + 1) (fun x y -> f x y)

let win x =
 match x with
 |'r' -> 'p'
 |'p' -> 's'
 |'s' -> 'r'
 |_ -> 'y'

let get x =
 match x with
 |'r' -> R
 |'p' -> P
 |'s' -> S
 |_ -> 0

let rec g c ls score = 
 match ls with
 |[] -> score
 |hd :: tl -> if (c = win hd) then (g 'x' tl score) else (g (win hd) tl (score + (get (win hd))))

let ans =[for i in 0..(K - 1) -> (g 'x' [for j in 0..(N / K) -> t.[i,j]] 0)] |> List.sum

ans
|>stdout.WriteLine