solve n xs ys = 2 * n - (maximum $ map f [0..n])
  where
    f i = length $ filter id $ zipWith (==) as bs
      where
        as = drop (n-i) xs
        bs = take i ys

main = do
  n <- readLn :: IO Int
  xs <- getLine
  ys <- getLine
  print $ solve n xs ys
