import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
readString = map BS.unpack . BS.words

getInt = readInt <$> BS.getLine
getString = readString <$> BS.getLine

simulate :: String -> String -> String -> Int
simulate [] [] s = length s
simulate (a : as) (b : bs) s
  | a : s == reverse (b : s) = simulate as bs (a : s)
  | otherwise = length (a : as) + length s + length (b : bs)

main = do
  n <- getInt
  [s] <- getString
  [t] <- getString
  if s == t
    then print $ length s
    else print $ simulate (reverse s) t ""
