import Control.Applicative ((<$>), (<*>), (<*))
import Control.Monad
import Data.List

main :: IO ()
main = do
  solve <$> getl read <*> getLine <*> getLine >>= print

solve :: Int -> String -> String -> Int
solve n s t = f n s t
  where
    f a [] _ = a
    f a xs ys
      | xs `isPrefixOf` ys = a
      | otherwise = f (a+1) (tail xs) ys

getl :: (String -> a) -> IO a
getl f = f <$> getLine
