import Control.Monad
import Data.List
import Control.Applicative

main = do
  n <- readLn
  [a,b,c] <- replicateM 3 getLine
  putStrLn $ show $ cnt a b c n

cnt :: [Char] -> [Char] -> [Char] -> Int -> Int
cnt (a:as) (b:bs) (c:cs) n
  |n <= 0 = 0
  |((a:as) == (b:bs)) && ((b:bs) == (c:cs)) = 0
  |length (filter (== a) [b,c]) == 1 = (+) 1 $ cnt as bs cs (n -1)
  |(b == c) = (+) 1 $ cnt as bs cs (n -1)
  |otherwise =  (+) 2 $ cnt as bs cs (n -1)
cnt _ _ _ 0 = 0  


