import Data.Char
import Data.List

main :: IO ()
main = do
  l1 <- getLine
  l2 <- getLine
  l3 <- getLine
  let [n, k] = map read $ words l1 :: [Int]
      [r, s, p] = map read $ words l2 :: [Int]
      t = l3
  print $ sum $ map (point r s p) $ concatMap g $ f k t

point :: Int -> Int -> Int -> Char -> Int
point r s p 'r' = p
point r s p 's' = r
point r s p 'p' = s
point _ _ _ _ = 0

f k = transpose . f' k

f' _ [] = []
f' k l = l1:f' k l2
  where (l1, l2) = splitAt k l

g l = snd $ foldl g' (' ', []) l
  where
    g' (cp, l') c
      | cp == c = (' ', l'++[' '])
      | otherwise = (c, l'++[c])