main :: IO()
main = do
    s <- getLine
    t <- getLine
    print $ getsolve s t
    
getsolve :: String -> String -> Int
getsolve s t
    | s == [] = 0
    | head s == head t = 1 + getsolve (tail s) (tail t)
    | otherwise = getsolve (tail s) (tail t)