import Control.Monad(replicateM)
import Data.List(isInfixOf)

main = do
  n  <- readLn
  if n == 0 then return ()
  else do
    s <- replicateM n getLine
    print $ sum $ map head $ scanl roll [1,2,3] s
    main

-- [Up,Front,Right]
--Express the function by manipulating the above three numbers
roll [u,f,r] s
  |isInfixOf s "orth" = [f,7-u,r]
  |isInfixOf s "ast"  = [7-r,f,u]
  |isInfixOf s "est"  = [r,f,7-u]
  |isInfixOf s "outh" = [7-f,u,r]
  |isInfixOf s "ight" = [u,r,7-f]
  |isInfixOf s "eft"  = [u,7-r,f]