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
      hands = g $ h $ f k t :: [Char]
  print $ sum $ zipWith (rsp r s p) t hands

rsp r s p 'r' 'p' = p
rsp r s p 's' 'r' = r
rsp r s p 'p' 's' = s
rsp _ _ _ _ _ = 0

f k = transpose . f' k

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

g = concat . transpose

h = map (h' ' ')

h' hp [c]
  | hn == hp = [head $ delete hp "rsp"]
  | otherwise = [hn]
  where hn = hand c
h' hp (c1:cs) = hn':h' hn' cs
  where (c2:_) = cs
        hn = hand c1
        hf = hand c2
        hn' = if hn == hp then head (delete hp $ delete hf "rsp")
                          else hn

hand 'r' = 'p'
hand 's' = 'r'
hand 'p' = 's'