import qualified Data.ByteString.Char8 as BS

main = do
  BS.getLine
  s <- BS.getLine
  t <- BS.getLine
  let ans = compute s t
  print ans

compute :: BS.ByteString -> BS.ByteString -> Int
compute s t = head
  [ BS.length s + d
  | (s1,d) <- zip (BS.tails s) [0..]
  , s1 `BS.isPrefixOf` t
  ]