main = interact $ show . sol . tail . words
    where
    sol [s, t] = length s + length t - comm (length s)
        where
        comm 0 = 0
        comm x
            | drop (length s - x) s == take x t = x
            | otherwise = comm $ x-1

