import Data.List (sort,tails)
import System.IO (isEOF)

main = do
    quit <- isEOF
    if quit then return () else do
        s1 <- getLine
        s2 <- getLine
        print $ solve s1 s2
        main

solve :: String -> String -> Int
solve s1 s2 = solve' (sort $ tails s1) (sort $ tails s2) 0
    where
    solve' [] _ n = n
    solve' _ [] n = n
    solve' (u:us) (v:vs) n
        | u < v = solve' us (v:vs) (max n (matchN u v))
        | u > v = solve' (u:us) vs (max n (matchN u v))
        | u == v = solve' us vs (max n (matchN u v))

    matchN "" _ = 0 
    matchN _ "" = 0 
    matchN (c:cs) (d:ds)
        | c == d = 1 + matchN cs ds
        | c /= d = 0