
main :: IO ()
main = do
    p <- getLine
    r <- getLine
    putStr $ show $ count 0 p r

count :: Int -> String -> String -> Int
count n [] [] = n
count n (x:xs) (y:ys) = if x == y then count (n + 1) xs ys else count n xs ys
