{-# LANGUAGE BangPatterns #-}

import qualified Data.ByteString.Char8 as B
import qualified Data.Set              as S

main :: IO ()
main = do
  _ <- B.getLine
  a <- B.getLine
  b <- B.getLine
  c <- B.getLine
  print $ solve a b c

solve :: B.ByteString -> B.ByteString -> B.ByteString -> Int
solve a b c = go 0 a b c
  where
    go !k xs ys zs = case mapM B.uncons [xs, ys, zs] of
      Nothing                        -> k
      Just [(x,xs1),(y,ys1),(z,zs1)] -> go (k + l) xs1 ys1 zs1
        where
          l = pred $ S.size $ S.fromList [x, y, z]