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

main :: IO ()
main = do
    n <- readLn :: IO Int
    ss <- getLine
    ts <- getLine
    let as = do
            (i, bs) <- zip [0..] (tails ss)
            let cs = take (length bs) ts
            guard $ bs == cs
            return i
    print $ head as + length ts