import qualified Data.ByteString.Char8 as BS

getString = BS.unpack <$> BS.getLine

simulate [] [] = 0
simulate (c1 : s) (c2 : t)
  | c1 == c2 = 1 + simulate s t
  | otherwise = simulate s t

main = do
  s <- getString
  t <- getString
  print $ simulate s t
