import Control.Applicative
import Data.List (inits,tails)

main = do
  n <- read <$> getLine :: IO Int
  ss <- tails <$> getLine
  ts <- reverse.inits<$> getLine
  print $ ((2*n)-) $ length.fst.head $ dropWhile (uncurry(/=)) $ zip ss ts
