import           Control.Monad
import qualified Data.Array.IO         as IO
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  [n, k] <- getIntList
  [r, s, p] <- getIntList
  t <- BS.getLine

  dp <- IO.newArray ((0,0),(n-1,2)) 0 :: IO (IO.IOUArray (Int, Int) Int)

  forM_ [0..(n-1)] $ \i ->
    if (i < k)
    then case BS.index t i of
           'r' -> IO.writeArray dp (i, 2) p
           's' -> IO.writeArray dp (i, 0) r
           'p' -> IO.writeArray dp (i, 1) s
    else do
      let (u, v, w) = case BS.index t i of
            'r' -> (0, 0, p)
            's' -> (r, 0, 0)
            'p' -> (0, s, 0)
      prev0 <- IO.readArray dp (i-k, 0)
      prev1 <- IO.readArray dp (i-k, 1)
      prev2 <- IO.readArray dp (i-k, 2)
      IO.writeArray dp (i, 0) (u + max prev1 prev2)
      IO.writeArray dp (i, 1) (v + max prev2 prev0)
      IO.writeArray dp (i, 2) (w + max prev0 prev1)

  let solve :: Int -> Int -> IO Int
      solve i res | i == k = return res
                  | otherwise = do x <- IO.readArray dp (n-1-i, 0)
                                   y <- IO.readArray dp (n-1-i, 1)
                                   z <- IO.readArray dp (n-1-i, 2)
                                   solve (i+1) ((max (max x y) z) + res)
  ans <- solve 0 0
  print ans