import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe
import qualified Data.Sequence         as Seq

readInt = fst . fromJust . BS.readInt
getInt = readInt <$> BS.getLine

main = do
  n <- getInt
  s <- Seq.fromList <$> getLine
  t <- Seq.fromList <$> getLine

  let solve i | i == n    = 2*n
              | otherwise =
                 let bs = Seq.drop i s
                     bt = Seq.take (n-i) t
                 in if bs == bt
                    then n+i
                    else solve (i+1)

  print $ solve 0