import Data.Array
import Data.List

main = print =<< sol <$> get <*> get <*> getLine

get = fmap read . words <$> getLine

sol [n,k] [r,s,p] t = sum [sub i | i <- [0..k-1]]
  where
  ar = listArray (0,n-1) t
  sub i = fst $ foldl' upd (0,' ') [ar!(i+j*k) | j <- [0..n `div` k], i+j*k < n]
  upd (q,h) 'r' = if h=='p' then (q,'r') else (q+p,'p')
  upd (q,h) 's' = if h=='r' then (q,'s') else (q+r,'r')
  upd (q,h) 'p' = if h=='s' then (q,'p') else (q+s,'s')
