import Data.List

main = getLine >> getContents >>= print . solve 0 . lines

solve :: Int -> [String] -> Int
solve n [xxs@(_ : xs), ys]
    | xxs `isPrefixOf` ys = n + length ys
    | otherwise = solve (n + 1) [xs, ys]
solve n [_, ys] = n + length ys
