import Control.Applicative
import Control.Monad

main :: IO ()
main = do
    xss <- getLine
    yss <- getLine
    putStrLn $ show (solve xss yss)

solve :: String -> String -> Int
solve xss yss = solve' xss yss 0
      where solve' []     []     n = n
            solve' (x:xs) (y:ys) n = if x == y 
                                     then solve' xs ys (n+1)
                                     else solve' xs ys n